Help

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

Solved
Jump to Solution
2283 1
cancel
Showing results for 
Search instead for 
Did you mean: 
Dennis_Drees
4 - Data Explorer
4 - Data Explorer

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:
Screenshot 2021-04-05 at 19.54.24

Any pointers would be much appreciated.

1 Solution

Accepted Solutions
acco
6 - Interface Innovator
6 - Interface Innovator

Hey @Dennis_Drees

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

– Anthony

See Solution in Thread

3 Replies 3
acco
6 - Interface Innovator
6 - Interface Innovator

Hey @Dennis_Drees

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

– Anthony

FACEPALM!
Many thanks, @acco !

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