Hi! 
I started playing with Retool today and I've ran into a problem with updating records in Airtable.
-
Goal: I want to update records in Airtable after updating them inline in Retool.
-
Steps: I've correctly set up event handler (Change cell -> Control query), written the API call and tested it in HTTPIE (works without any problems).
-
Details: I written a request that works fine in HTTPIE/Postman, but when I fire it in Retool, it responds with this error:
{
"error": {
"type": "INVALID_REQUEST_MISSING_FIELDS",
"message": "Could not find field \"fields\" in the request body"
}
}
Here's the body of my request
{
"typecast": true,
"fields": {
"category": "rec........",
"type": "rec......",
"if_split": "yes"
}
}
It calls the Airtable API using the PATCH method, using correct record ID fetched from using selectedRow.id
.
The body is populated with values from changesetArray['0'].category,
changesetArray['0'].typeand
changesetArray['0'].if_split`, as I'm recording only a single record.
I copy-pasted results from the green preview window into HTTPIE and it worked fine.
Any help on this would be appreciated!
Hi @michal.platek - welcome to the community!
It is helpful sometimes to see the actual API request that is sent by Retool. You can find it at Output section, at API Request tab:
If you cannot find the bug yourself feel free to send the contents of this API Request field.
Hope this helps
Hi! Thanks for the reply!
I checked the content of the request and the "fields" key is there, but maybe I missed something. Can you spot the cause of this error? 
{
"request": {
"url": "https://api.airtable.com/v0/appRQd7s........./tblEnqjC........./recEpGOActDu.....",
"method": "PATCH",
"body": "{\"typecast\":true,\"fields\":{\"category\":\"recZeAnvlF7Z.....\",\"type\":\"recvCTVOfkfo.....\",\"if_split\":\"Tak\"}}",
"headers": {
"User-Agent": "Retool/2.0 (+https://docs.tryretool.com/docs/apis)",
"Authorization": "---sanitized---",
"ot-baggage-requestId": "undefined",
"x-datadog-trace-id": "7696099981458159643",
"x-datadog-parent-id": "7660510304561139487",
"x-datadog-sampling-priority": "1",
"x-datadog-tags": "_dd.p.dm=-1",
"traceparent": "00-00000000000000006ace0a284eb4381b-6a4f9988ed960f1f-01",
"tracestate": "dd=t.dm:-1;s:1",
"X-Retool-Forwarded-For": "213.134.167.104"
}
},
"response": {
"data": {
"error": {
"type": "INVALID_REQUEST_MISSING_FIELDS",
"message": "Could not find field \"fields\" in the request body"
}
(and the rest of the response - I hid the base, table and record ID for obvious reasons)
Try adding Content-Type
: application/json
HTTP header to your query. It should look like this:
I played with my Airtable query and was able to reproduce your error when I removed that header.
Let me know if that helps
Hey @michal.platek - in case this solved your problem I suggest you mark it as a Solution so that others can benefit this conversation
That's the solution - thank you! I checked Retool's documentation and noticed the part, where it says that it is required to send Content-Type header for sending raw requests with a nested JSON structure, and it did the trick.
1 Like
Great @michal.platek - if you need more help feel free to send me a DM
2 Likes