Trouble POSTing to the bubble data api from python

I am having quite a time sending data to bubble. I am trying to create a record, with just one text field named ‘slug’:

In python, I have:

import requests
url = 'https://tracktradecrypto.com/version-test/api/1.1/obj/floor_slugs'
myobj = {'slug': 'test4'}
hed = {
    'Authorization': 'Bearer ' + 'MYAPIKEY',
    'Content-Type': 'text/plain;application/x-www-form-urlencoded;charset=utf-8'
}
req = requests.post(url, headers=hed, data=myobj)
print(req.text)

I get a success from bubble:

{
    "status": "success",
    "id": "1655594157181x183111748288238500"
}

However, the contents in the bubble db are just null:

When GETting from bubble, I see that the field named “slug” doesnt even appear. Here is the output:

    {
        "Created Date": "2022-06-18T23:10:51.644Z",
        "Created By": "admin_user_track-trade-v1_test",
        "Modified Date": "2022-06-18T23:10:51.644Z",
        "_id": "1655593851644x178210410496320480"
    },
    {
        "Created Date": "2022-06-18T23:15:29.164Z",
        "Created By": "admin_user_track-trade-v1_test",
        "Modified Date": "2022-06-18T23:15:29.164Z",
        "_id": "1655594129164x170547471512927140"
    },
    {
        "Created Date": "2022-06-18T23:15:57.181Z",
        "Created By": "admin_user_track-trade-v1_test",
        "Modified Date": "2022-06-18T23:15:57.181Z",
        "_id": "1655594157181x183111748288238500"
    }

Any ideas??

w3schools.com/python/showpython.asp?filename=demo_requests_post_json

Try this method.

This seems to be the same code as what I posted?

So one obvious issue is ‘Slug’ is a built-in field (duh!), but posting with a new field still doesnt work…

Okay lets try another thing.

Have you enabled access to your API via settings? You need to access API to the thing you’re trying to change/delete/add.

This topic was automatically closed after 70 days. New replies are no longer allowed.