Python Forum
How to pass list of values to a API request URL
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to pass list of values to a API request URL
#1
In the below script, I'm pulling data from level opportunity api, take contact from opportunity and pass it to level contact api and get all the fields related to that contact. After print(contacts_url), I'm getting 50 urls with contact ids, but after print(content_load) at the end , I'm getting only 1 contact data.
How to pass all the contacts in the list to contact api url and get all the contacts data?

import requests
import json
r_o = requests.get('https://api.lever.co/v1/opportunities', auth=('I47euT', ''))
ob = json.loads(r_o.text)

for i in range(len(ob["data"])):
    lst = []
    lst.append(ob["data"][i]['contact'])
    contacts_url='https://api.lever.co/v1/contacts/'
    contacts_url=contacts_url+ob["data"][i]['contact']
    print(contacts_url)

r_contact = requests.get(contacts_url, auth=('I47euT', ''))
ob = json.loads(r_contact.text)
content_load = ob['data']
print(content_load)
Yoriz write Sep-28-2021, 11:09 AM:
Please post all code, output and errors (in their entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  remove duplicates from dicts with list values wardancer84 27 1,190 May-27-2024, 04:54 PM
Last Post: wardancer84
  Copying the order of another list with identical values gohanhango 7 1,405 Nov-29-2023, 09:17 PM
Last Post: Pedroski55
  Search Excel File with a list of values huzzug 4 1,446 Nov-03-2023, 05:35 PM
Last Post: huzzug
  How to pass encrypted pass to pyodbc script tester_V 0 995 Jul-27-2023, 12:40 AM
Last Post: tester_V
  Comparing List values to get indexes Edward_ 7 1,432 Jun-09-2023, 04:57 PM
Last Post: deanhystad
  Adding values with reduce() function from the list of tuples kinimod 10 3,014 Jan-24-2023, 08:22 AM
Last Post: perfringo
  user input values into list of lists tauros73 3 1,244 Dec-29-2022, 05:54 PM
Last Post: deanhystad
  AttributeError: 'list' object has no attribute 'values' ilknurg 4 15,509 Jan-19-2022, 08:33 AM
Last Post: menator01
  Need to parse a list of boolean columns inside a list and return true values Python84 4 2,293 Jan-09-2022, 02:39 AM
Last Post: Python84
  List of dataframe values beginning with x,y or z glidecode 3 2,080 Nov-08-2021, 10:16 PM
Last Post: glidecode

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020