Problems with data submission using create_all.json method from API

I have been using some Python scripts for some time now to submit data points to a couple of my goals. Since yesterday they are no longer working. The issue seems to be with the create_all methods of the Beeminder API. Instead of posting my scripts, which contain a lot of irrelevant stuff, I’ll post a minimum example that I think should work, but doesn’t. The code is the following:

#!/usr/bin/python3

from time import time
import json
import requests

API_URL = 'https://www.beeminder.com/api/v1/'
auth_token = "THEAUTHTOKEN" # my auth token
user = "davitenio"
goal = "totalpomodoros"

timestamp_now = round(time())
data = [
        {
            'timestamp': timestamp_now,
            'value': 42,
            'comment': 'this is a test'
        }
]

print("Submitting the following data to {}: {}".format(goal, data))

path = 'users/{}/goals/{}/datapoints/create_all.json'.format(user, goal)
datapoints = json.dumps(data)
args = {'auth_token': auth_token, 'datapoints': datapoints}
response = requests.post(API_URL + path, params=args)
print(response.json())

When I run this script, it prints the following:

Submitting the following data to totalpomodoros: [{'comment': 'this is a test', 'timestamp': 1414842516, 'value': 42}]
{'successes': [], 'errors': ['{"comment":"this is a test","timestamp":1414842516,"value":42}']}

As can be seen, I am getting the submitted data listed under errors as a response. Moreover, my goal is not updated. Shouldn’t the above code work and successfully submit data?

1 Like

Just deployed a fix for this. Please let me know if you’re still seeing issues!

Bethany

1 Like

Excellent! My scripts seem to be working again. Thanks!

By the way, if you haven’t done so, consider writing some regression tests to help ensure that this bug, and the other bugs you are fixing, will not be accidentally reintroduced in the future.

Keep up the good work!

1 Like