Skip to main content

Cannot Get Patch Request To Work


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

Forum|alt.badge.img+19
  • Inspiring
  • 3264 replies
  • November 11, 2019

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


  • Author
  • New Participant
  • 3 replies
  • November 11, 2019

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


Forum|alt.badge.img+19
  • Inspiring
  • 3264 replies
  • November 11, 2019
Suraj_Kapoor wrote:

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.


JonathanBowen
Forum|alt.badge.img+18

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


JonathanBowen
Forum|alt.badge.img+18
Suraj_Kapoor wrote:

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


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


  • Author
  • New Participant
  • 3 replies
  • November 11, 2019

Thank you! That did the trick. Appreciate your help


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


JonathanBowen
Forum|alt.badge.img+18
sadhika_bhatia wrote:

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


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


Reply