Error 422 (Unprocessable Entity) for PATCH request using fetch()

Hi all

I’m trying to update records in a table using vanilla javascript (because I’m building a Bookmarklet, so curl or node won’t work). I’m stuck on a user error “Unprocessable Entity” and the response is of type “cors”, so perhaps there is something wrong with my request headers?

fetch("https://api.airtable.com/v0/appfiPFiZHqEAsjAJ/Table%201",
	{
		method: "patch",
		headers: {
			"Authorization": "Bearer MY_KEY",
			"Content-type": "application/json",
			"accept": "application/json"
		},
		body: {
			"records": [
					{
						"id": "recSKCdIGgAGRUc5c",
						"fields": {
							"Field One": "Bla",
							"Field Two": "BlaBla",
							"Field Three": "Blubb",
						}
					}
			]
		}
	})

This returns:

Any pointers would be much appreciated.

Hey @Dennis_Drees

I believe with fetch() you have to JSON.stringify() your body property, yeah?

– Anthony

1 Like

FACEPALM!
Many thanks, @acco !

Been there, done that many times :sweat_smile: Happy that was it

This topic was solved and automatically closed 3 days after the last reply. New replies are no longer allowed.