I have the following script that are returning response 400 but I am unable to find where the mistake in the payload is.
I am getting an error that raise this: JSONDecodeError("Expecting value", s, err.value) from None I assume that the payload is with wrong data format, but I have running this without the loop and it has been working.
API_Key = os.getenv("API_Key")
url = "https://app.pendo.io/api/v1/aggregation"
dates = pd.date_range(start='1/1/2022', end='10/1/2022',
freq='M').strftime("%Y-%m-%d").tolist()
list_epoch=[]
for i in dates:
epoch = int(time.mktime(time.strptime(i, "%Y-%m-%d")))
list_epoch.append(epoch)
days = [31,28,31,30,31,30,31,31,30,31,30,31,31,28,31,30,31,30,31,31,30]
for var1, var2 in zip(list_epoch,days):
data_payload = {
"response": {
"mimeType": "application/json"
},
"request": {
"pipeline": [
{
"source": {
"events":{
"featureId": "iNdfepY576Yo-x1itQUp5T99z8Y"
},
"timeSeries": {
"first": var1,
"count": -var2,
"period": "dayRange"
}
}
}
]
}
}
print(data_payload)
headers = {
'x-pendo-integration-key': API_Key,
'content-type': "application/json"
}
response = requests.post(url, json=data_payload, headers=headers)
print(response)
response_dictionary = json.loads(response.content)
´´´