I am trying to update a record’s attachments field.
I am doing this successfully with curl, and also I have python code that successfully pulls records from the table; however when I add code to that which tries the PATCH, I get a “Could not parse request body” 422 response.
Below is the code.
Thanks!
import requests
import datetime
import json
auth_token=‘keyXXXXmJVG’
hed = {‘Authorization’: 'Bearer ’ + auth_token, ‘Content-Type’: ‘application/json’}
url = ‘https://api.airtable.com/v0/applXXXXmLfek/Table%202/recthrgH5KVMEMglc’
print(“GET’ing records…”)
# THIS REQUEST WORKS:
response = requests.get(url, headers=hed)
print(response.json())
r2 = { ‘fields’: { ‘mytext’: ‘success’}}
print(“PATCH request…”)
# THIS REQUEST FAILS WITH 'Could not parse request body’
presp = requests.patch(url, headers=hed, data=r2)
print(presp.text, presp)