Nov 11, 2019 07:42 AM
article_url = "https://api.airtable.com/v0/appxxxxxxxxxxx/articles/row_id?api_key=APIKEY"
data = {"fields" : {"contacted" : "hello world"}, "typecast":True}
patch_article_data = requests.patch(article_url, data=data)
I don’t understand why the above doesn’t work doing a patch request. I’ve tried many variations, including without typecast. I get the following response.
{u'error': {u'message': u'Invalid request: parameter validation failed. Check your request data.', u'type': u'INVALID_REQUEST_UNKNOWN'}}
Nov 11, 2019 08:58 AM
I’m pretty sure a record ID is required for a PATCH.
Nov 11, 2019 09:00 AM
In the example, row_id is the record_id. Should it be a param instead?
Nov 11, 2019 09:02 AM
Without a complete review of the underlying code I can only say that I think a PATCH payload (the data) must be an array of records to be updated.
Nov 11, 2019 09:03 AM
Hi @Suraj_Kapoor - I’m assuming you are using the Python requests library here. This is some code that I implemented for a patch request:
api_url = 'https://api.airtable.com/v0/YOUR_APP_ID/YOUR_TABLE_NAME/' + id
headers = {
'Content-Type': 'application/json',
'Authorization': 'Bearer YOUR API KEY'
}
data = {
"fields": {
"your_field_name": "value"
}
}
response = requests.patch(api_url, headers=headers, json=data)
Looking at this post:
it recommends using the API key in the headers, rather than as a URL param. Try this, hopefully will work out for you.
JB
Nov 11, 2019 09:06 AM
As per the API docs for your base, the record id should be in the patch request URL:
curl -v -X PATCH https://api.airtable.com/v0/APP_ID_HERE/TABLE_NAM_HERE/rec123123123
Nov 11, 2019 09:19 AM
Thank you! That did the trick. Appreciate your help
Mar 27, 2022 11:26 AM
I am also facing the same issue that getting this error for patch request. I have added the API key in the header and the view in the query parameter but still getting the same error
Mar 28, 2022 01:21 PM
Did you pass the ID of the record you wanted to update? e.g.:
https://api.airtable.com/v0/APP_ID_HERE/TABLE_NAM_HERE/rec123123123
Note the record ID on the end, this is the record you want to update