Skip to main content
Solved

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

  • April 5, 2021
  • 3 replies
  • 119 views

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.

Best answer by acco

Hey @Dennis_Drees

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

– Anthony

3 replies

Forum|alt.badge.img+6
  • Participating Frequently
  • 23 replies
  • Answer
  • April 5, 2021

Hey @Dennis_Drees

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

– Anthony


  • Author
  • New Participant
  • 1 reply
  • April 5, 2021

Hey @Dennis_Drees

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

– Anthony


FACEPALM!
Many thanks, @acco !


Forum|alt.badge.img+6
  • Participating Frequently
  • 23 replies
  • April 5, 2021

FACEPALM!
Many thanks, @acco !


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