I am trying to add data to metric, but i am getting in response Status Code 400, which is not listed in docs
Here's some code: (based on script on data submit page)
Python 3
# need 1 data point every 5 minutes
# submit random data for the whole day
total_points = int((60 / 5 * 24))
for i in range(total_points):
ts = int(time.time()) - (i * 5 * 60)
value = random.randint(0, 99)
params = json.dumps(
{
"data": {
"timestamp": 0,
"value": 0
}
}
)
headers = {'Content-Type': 'application/json', 'Authorization': f'Bearer {api_key}'}
r = requests.post(
f'https://api.statuspage.io/v1/pages/{page_id}/metrics/{metric_id}/data',
params=params,
headers=headers)
# response = r.status_code
if (r.status_code >= 400):
genericError = "Error encountered. Please ensure that your page code and authorization key are correct."
print(genericError)
print(f'Status code = {r.status_code}')
print(f'Attempt no.{str(i + 1)}')
else:
print("Submitted point " + str(i + 1) + " of " + str(total_points))