#Is there a reference somewhere for how to update a record over the API in Python?

30 messages · Page 1 of 1 (latest)

humble void
harsh mortar
harsh mortar
patent void
#

Do you have any flows setup that would revert this?

harsh mortar
#

I don't have any flows set up at all.

humble void
#

What is the response body from the api?

harsh mortar
# humble void What is the response body from the api?

{'data': {'catalognumber': '3-3-F', 'date_created': '2021-11-24T10:55:11.000Z', 'date_updated': '2022-12-14T19:54:52.000Z', 'donated': False, 'donor_id': None, 'filmdamaged': False, 'filmincomplete': False, 'firstdraftdone': False, 'firstdraftneeded': False, 'firstdrafturlpatreon': None, 'firstdrafturlvideo': None, 'iadescription': None, 'iaframescansuploaded': False, 'iakeywordsdone': False, 'iareadmeuploaded': False, 'iasoundtrackuploaded': False, 'iauploadverified': False, 'iaurl': None, 'id': 1000, 'notes': None, 'originalyoutubetitle': None, 'orphanfilm': True, 'orphansound': False, 'patreonpostbody': None, 'presound': False, 'problem': False, 'publisher_id': 2, 'releasevideouploaded': False, 'restoredone': False, 'restoreurlpatreon': None, 'restoreurlyoutube': None, 'scanned': True, 'series_id': 1000, 'slug': 'tips-on-writing-the-short-story-by-howard-f-decker', 'sort': None, 'sounddamaged': False, 'soundincomplete': False, 'soundtrack_media_type_id': None, 'title': 'Tips on Writing the Short Story by Howard F. Decker', 'uploadedtoia': False, 'user_created': '8f72bdd1-5be0-4f3d-90fa-9e186bc3df37', 'user_updated': '8f72bdd1-5be0-4f3d-90fa-9e186bc3df37', 'year': 1966, 'youtubedescription': None, 'youtubeuploaddate': None}}

humble void
#

That's odd. Seems like everything is working. Maybe try turning that dict into a string and passing that to the body.

harsh mortar
#

I'm ashamed to say I probably don't know how to do that.

#

Changing the values variable assignment to values = {'data':{'problem': True}} doesn't change anything either.

humble void
#

Oh, try requests.patch(api_url, data=values)

harsh mortar
humble void
#

And requests.patch(api_url, data="{'problem': true}")?

harsh mortar
#

I wish I could see how Directus is interpreting what I'm sending it.

humble void
#

You could set LOG_LEVEL=debug in the .env file of directus to get more details

harsh mortar
#

I'll try that.

harsh mortar
humble void
#

Did you restart directus?

harsh mortar
#

Yes. I have it running straight off the command line so I can watch the log. I control-C'ed it and re-ran npx directus start

humble void
#

You could also use a rest client to see if you can manually update directus outside of python.

harsh mortar
#

Let me give that a try

humble void
#

Then you at least know if it is a problem in Directus or something not working as expected with python 😄

harsh mortar
humble void
#

So my guess was correct that python is doing something weird. ^^

harsh mortar
#

Yeah. The question is what. Thanks for the suggestion though.

sand lodge
#

Try using a incoming request inspector like https://webhook.site/ and compare the not working python request and the working rest client request and see if there are any differences