Reputation: 1721
I'm having difficulty performing a simple GET request to a vendor API. I suspect there's a problem with my params varable containing too many elements but I'm unsure of how to fix the problem. I've tried several variations but to no avail.
Solutions in similarly named posts don't appear to be relevant to this scenario (JSON response data from API calls).
Below is the Python code that is raising this error & a screenshot of my shell output. Please advise. Side note: I'm no expert in Python.
import requests
import re
company_ids = '11407'
def call_and_append():
headers = {
'Authorization': 'Bearer REDACTED',
}
params = (
('companies',company_ids+'/people')
)
response = requests.get(
'https://api.mattermark.com/companies/',
headers=headers,
params=params
)
with open(r'C:\Users\etherealessence\Desktop\personnel_data.json', 'a+') as personnel_data:
personnel_data.write('{}\n'.format(response.text))
return response.json()
call_and_append()
Upvotes: 0
Views: 4326
Reputation: 31654
The error shows you everything:
for k, vs in to_key_val_list(data):
From this, you can see it required a dict
. Something like follows:
payload = {'key1': 'value1', 'key2': 'value2'}
r = requests.get('https://httpbin.org/get', params=payload)
So, you should change next to a dict to make it work.
params = (
('companies',company_ids+'/people')
)
Detail refers to this.
Upvotes: 1