Help

Re: Cannot Get Patch Request To Work

3912 1
cancel
Showing results for 
Search instead for 
Did you mean: 
Suraj_Kapoor
5 - Automation Enthusiast
5 - Automation Enthusiast
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'}}

8 Replies 8

I’m pretty sure a record ID is required for a PATCH.

image

Suraj_Kapoor
5 - Automation Enthusiast
5 - Automation Enthusiast

In the example, row_id is the record_id. Should it be a param instead?

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.

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

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

Suraj_Kapoor
5 - Automation Enthusiast
5 - Automation Enthusiast

Thank you! That did the trick. Appreciate your help

sadhika_bhatia
4 - Data Explorer
4 - Data Explorer

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
image

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