uber-api

Uber Eats API - Fail to collect reports (Could not parse json: readObjectStart: expect { or n, but..)


We are facing an error when we are trying to request UberEats API to collect report about our restaurants based on the Ubereats documentation here.

The error :


'{"error":"Could not parse json: readObjectStart: expect { or n, but found \x00, error found in #0 byte of ...||..., bigger context ...||..."}'

We tried to run the query in python and postman and still facing the same error.

Need help to understand where we failed.

Here the python code run in VSC

import requests
import json

payload = {
    "report_type": "FINANCE_SUMMARY_REPORT",
    "store_uuids": "xxx",
    "start_date": "2022-09-01",
    "end_date": "2022-09-15"
}

headers = {
    "authorization": "Bearer xxx"
}

report_response = requests.post('https://api.uber.com/v1/eats/report', data=payload, headers=headers)

report_response.text
'{"error":"Could not parse json: readObjectStart: expect { or n, but found \x00, error found in #0 byte of ...||..., bigger context ...||..."}'

Best regards,


Solution

  • You have to convert the payload to valid JSON string and send the request.

    headers = {
      "Authorization" : "*********",
      "Content-Type" : "application/json"
    }
    
    import json
    
    response = requests.post("https://api.uber.co/v1/eats/report", data = json.dumps(payload), headers=headers)