user3904183
user3904183

Reputation: 51

Uber API - requests endpoint cannot read read json

I am trying to generate a POST request for the requests endpoint in the following python code:

import requests
...
response = requests.post(
'https://sandbox-api.uber.com/v1/requests',
headers = {
    'Authorization': 'Bearer %s' % access_token,
    'Content-Type': 'application/json'
},
params={"start_latitude":"37.334381","start_longitude":"-121.89432","end_latitude":"37.77703","end_longitude":"-122.419571","product_id":"a1111c8c-c720-46c3-8534-2fcdd730040d"})
data = response.json()

The access_token was obtained using request scope during authorization. The response json is : {"message": "Unable to parse JSON in request body.", "code": "invalid_json"}

Need help in formatting the request properly. Thanks.

Upvotes: 2

Views: 630

Answers (1)

user3904183
user3904183

Reputation: 51

Figured out the problem - had to replace the params field with a data field and wrap the dict with json.dumps() before sending it off.

Upvotes: 3

Related Questions