Airtable API - PATCH Body Syntax

Hi All :wave: ,

I am having issues with the HTTP request module creating a PATCH body for my Airtable base API. Even with an empty response ( “fields”:{} ) I am getting a 422 response. Same credentials work fine for a GET (so no issue with Auth headers) and a test to https://httpbin.org/patch responds with the expected submission “fields”: {}

Postman works fine with URL and body (empty and the variables I’d like to use) and the debug comes back with what I think is correct (although there’s some nesting of JSON in the debugger.

Details are -

HTTP Request settings (using a page parameter for the unique record)

response body recieved in Appgyver (per output 2 for 400-500 reponse)

{“error”:{“type”:“INVALID_REQUEST_BODY”,“message”:“Could not parse request body”}}

HTTPBIN response (when substituting the URL)

{“args”:{},“data”:""{\“fields\”:{}}"",“files”:{},“form”:{},“headers”:{“Accept”:“application/json”,“Accept-Encoding”:“gzip, deflate, br”,“Accept-Language”:“en-AU,en;q=0.9,en-US;q=0.8”,“Authorization”:“Bearer key___________”,“Content-Length”:“17”,“Content-Type”:“application/json”,“Dnt”:“1”,“Host”:“httpbin.org”,“Origin”:“https://preview.appgyver.com”,“Referer”:“https://preview.appgyver.com/",“Sec-Ch-Ua”:"” Not;A Brand";v=“99”, “Google Chrome”;v=“91”, “Chromium”;v=“91"”,“Sec-Ch-Ua-Mobile”:"?0",“Sec-Fetch-Dest”:“empty”,“Sec-Fetch-Mode”:“cors”,“Sec-Fetch-Site”:“cross-site”,“Sec-Gpc”:“1”,“json”:"{“fields”:{}}",“url”:“https://httpbin.org/patch”}

Debug detail for HTTPBIN

BODY
{ 3 items
“value”: string"{“fields”:{}}"

“key”: string"{“fields”:{}}"

“source”: string"str"
}

Airtable debug (that resulted in a 422 eror)

BODY
{ 3 items
“value”: string"{“fields”:{}}"

“key”: string"{“fields”:{}}"

“source”: string"str"
}

Any quick tips or help, I have already upvoted API Direct Integration feature too :ok_hand:

Update - have moved the raw string into the Encoded_JSON formula per some foum posts, still failing :frowning:

Cheers,

Paul

It appears you are trying to PATCH empty field data? Why would you need to do that? I would think a an empty PUT request would be best.

Thanks John, just using an empty PATCH to test and avoid any variable/field issues (an empty patch returns the original record unchanged). Airtable doesn’t like PUT unless you provide the whole record (destructive PUT). Can get this going through every other means but just not via AppGyver. Shame as it’s by far the quickest and feature full low code app I’ve seen so far (for the price). This is a deal breaker for Airtable record updates however…and yes, am looking to move away from Airtable for prototyping too (supabase etc.)

I just suggested PUT because it appeared you were trying to be destructive by clearing out the whole fields structure.
Are you appending the record id to the URL?

Yep - via a function to utilise the page parameter per record selected prior to page entry

https://api.airtable.com/v0/appmkAi2IRsswKuBc/Current%20Meters/”+params.RecordID

Cheers,

-P

Ok i’ll test this out on my end and get back to you…

Oh wait … I think your Request Body needs to be a formula. You are sending a literal string instead of a json object?

I changed it to a formula (per the last screenshot) and added typecast (not that an empty object needs it) per some posts I saw that had formula ENCODED_JSON entries…

appreciate your help !!

Cheers,

-P

Ok so I just successfully PATCHed one of my Airtable records, so PATCH does work. And I also sent an empty fields object like you did and it came back Success (although nothing changed).
But you have to send your Request Body as a formula, not a static text.

Yea you dont need to ENCODE_JSON there.

That’s great news, I might just re-create a base and start again, I’m sure I’ve looked at this too long :frowning:

Would you mind sharing your http request module detail so I don’t end up where I began ?

Sorry - just so I am understanding - Request Body is a formula but just the JSON string or concatenated variables ?

really appreciate it !!

-P

Yes. Here is the base setup for HTTP REQUEST:
Capture

And here is the Header:
Capture2

1 Like

Awesome - plain string in the function = FTW !!

Thanks John, veeery much appreciated !!

1 Like