Beeminder Forum

Error creating datapoints

Hi, this feels like I must be missing something obvious but I can’t figure it out.

I’m trying to create multiple datapoints through the Beeminder API, using the python requests library.

datapoint = {"value": 100, "comment": "test", "daystamp": "20210203"}
payload = {"auth_token": XXXX, "datapoints":[datapoint]}
resp = requests.post(URL, json=payload)

This gives a 422 with the response: '{"errors":{"value":["can\'t be blank","is not a number"]}}'.

However using the same data to create a single datapoint works just fine.

resp2=requests.post(URL, json={"auth_token": XXXX, **datapoint})

Any thoughts on what I might be doing wrong?

2 Likes

What’s the actual network traffic look like? Usually, this sort of issue clears up once you see the actual HTTP calls.

1 Like

The documentation would seem to imply timestamp is required when submitting multiple datapoints at once using create_all.json where it is optional when submitting just one using datapoints.json.

In fact, value seems to be the only required property when creating just one and all of timestamp, value, and comment are required on create_all.

Sorry, this was my mistake – was using the same url in both calls (datapoints.json rather than datapoints/create_all.json). And looks like the documentation is incorrect, I can create multiple datapoints with daystamp only just fine.

Thanks for your help!

2 Likes

Thanks for the feedback. Ticket created:

1 Like