Post API Payload not being passed


I am trying to implement a python script to fectch data. Same logic as the Micrtronics API. In the following method, I am getting 200 as a response but the payload is not being passed and I am getting an invalid format. Possible to help?

Fetch histdata using the API

def fetch_histdata(headers, device_id):

payload = {
    "select": [
query_string = urlencode(payload)
print(f"Fetching historical data for Customer {customer}, Site {device_id}...")
url_with_query = f"{histdata_url.format(device_id=device_id)}?{query_string}"
response = requests.get(url_with_query, headers=headers)

You need to pass the query as value to the “json” key without urlencoding it.

query_string = "json=%s" % json.dumps(payload)

1 Like

Thank you Julian, it worked. Appreciate that


Nice to hear that you have already found the solution.

Best regards