loading...

Airtable POST/PATCH errors solved

marcomow profile image Marko Kolombo ・1 min read

After a frustrating evening I finally found out WHY the Airtable API was always rejecting my humble POST/PATCH requests, a.k.a. requests that needed parameters to be sent as body.

I was stuck at some errors:

{“type”:“INVALID_REQUEST_MISSING_FIELDS”,“message”:“Could not find field “fields” in the request body”}}.`

{"error":{"type":"INVALID_REQUEST_UNKNOWN","message":"Invalid request: parameter validation failed. Check your request data."}}

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

THE SOLUTION WAS...just to add this to the json: "typecast:true".
Yes, everything else was ok.

From the Airtable's API documentation:
"The Airtable API will perform best-effort automatic data conversion from string values if the typecast parameter is passed in (click to show example). Automatic conversion is disabled by default to ensure data integrity, but it may be helpful for integrating with 3rd party data sources."

To be honest this was a bit hidden, but hey, I'm writing this post specially for you, struggling for the win (read: for myself when I'll forget).

An example json

`javascript
{
"fields": {
"customer": [
"recMmE0pTasdGqkEw"
],
"date": "2019-07-15",
"from": "2019-06-15",
"to": "2019-06-30",
"currency": "USD"
},
typecast:true

}
`

edit:
I just found out that after I sent the request with typecast:true, now all the requests are passed smoothly without an error!

Posted on by:

marcomow profile

Marko Kolombo

@marcomow

Google Apps Script Developer @Visma

Discussion

markdown guide
 

Thanks for posting this! I was trying to do the same thing with python and couldn't figure out what the issue was. I passed my payload with json= instead of params= and it worked like a charm! Thanks again!