Another Download Tool/cURL Question; -d flag?
- S'abonner au fil RSS
- Marquer le sujet comme nouveau
- Marquer le sujet comme lu
- Placer ce Sujet en tête de liste pour l'utilisateur actuel
- Marquer
- S'abonner
- Sourdine
- Page imprimable
- Marquer comme nouveau
- Marquer
- S'abonner
- Sourdine
- S'abonner au fil RSS
- Surligner
- Imprimer
- Signaler au modérateur
I have some experience using the Download tool, even with some especially difficult APIs that seem to have their own way of doing things that make no sense. One such API, Airtable, is causing some grief in that this POST cURL:
cURL -v -XPOST https://api.airtable.com/v0/[airtable table name] \ -H "Authorization: Bearer [API_KEY]" \ -H "Content-type: application/json" \ -d '{ "fields": { "Field 1":"Value 1", "Field 2":"Value 2" } }
returns an Error from Airtable's API saying: "{"error":{"type":"INVALID_REQUEST_MISSING_FIELDS","message":"Could not find field \"fields\" in the request body"}}" when I use the Download tools.
All the Headers and Endpoints are setup, it's just the stupid -d flag with no specific field or key for that JSON body.
Corroborating this, I loaded the cURL into Postman and I noticed that there is no "key", just POST'ing the JSON in the raw Body successfully performs the HTTP call. How do I translate this into the Download tool?
(I have referenced this excellent KB article on Download Tool & HTTP calls link)
Résolu ! Accéder à la solution.
- Marquer comme nouveau
- Marquer
- S'abonner
- Sourdine
- S'abonner au fil RSS
- Surligner
- Imprimer
- Signaler au modérateur
Compose your JSON as a field (you probably already do this).
Then in the 'payload' tab use the 'Take Query String/Body from a field' option, and select your field.
This represents the raw body that is passed through in postman.
Ben
- Marquer comme nouveau
- Marquer
- S'abonner
- Sourdine
- S'abonner au fil RSS
- Surligner
- Imprimer
- Signaler au modérateur
Thanks @BenMoss for the reply. Right now I just have a single JSON constructed in a formula field. I have tried both maintaining the spaces and indentation, as well as collapsing it all into one line.
Here is the macro setup for Airtable. The data field stores the JSON value that is passed into the macro input.
Here's a test JSON created in a formula field. This is what is passed into the data field. As you can see from the errors, Airtable is still returning 422 Unprocessable errors
- Marquer comme nouveau
- Marquer
- S'abonner
- Sourdine
- S'abonner au fil RSS
- Surligner
- Imprimer
- Signaler au modérateur
Ok, circling back on this thread, I found that by whatever strangeness, I was able to get the Download tool working when I changed the header from Content-Type to Content-type and this is the only variable I can recall tweaking to allow me to successfully Create records with this API.
If anyone is interested :-)
