I have a pandas data frame that I am converting to a list of dicts, and then trying to send those to an API using the request module. A sample of the json:
[{
"street": "43 street road",
"secondary": "",
"city": "city",
"state": "st",
"zipcode": "12345",
"match": "invalid",
"candidates": "1"
}, {
"street": "65 road ave",
"secondary": "",
"city": "city",
"state": "st",
"zipcode": "12345",
"match": "invalid",
"candidates": "1"
}, {
"street": "123 road street",
"secondary": "815",
"city": "city",
"state": "st",
"zipcode": "12345",
"match": "invalid",
"candidates": "1"
}]
and here is the code I am trying to use to send it to the API
import requests
auth_id = 'id'
auth_token = 'token'
url = f'https://us-street.api.smartystreets.com/street-address?auth-id={auth_id}&auth-token={auth_token}'
some_pd_addresses = pd.DataFrame(some_file_path)
dict_addresses = some_pd_addresses.to_dict(orient='records')
Headers = {'Content-Type': 'application/json', 'Accept':'application/json'}
r = requests.post(url, json = json.dumps(dict_addresses[1:11]), headers=Headers)
When I execute this code, I get the error: json.decoder.JSONDecodeError: Extra data: line 1 column 5 (char 4) even though I can run this JSON through a Linter to confirm that it is a valid JSON. Where am I going wrong?