API Export to Airtable

I figured out how to connect and authenticate my AirTable API export, but I get this error message:

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

I don’t have anything in the “body” of the API Export, but I made the column names in my Parabola match the ones in my airtable.

Hey Brett! When you’re doing an API Export to Airtable, you do need to map fields in the Body.

Your body should look something like this:

  {
      "fields": {
        "Airtable column name": "{matching Parabola column name}",
        "Airtable column name 2": "{matching Parabola column name 2}",
        "Airtable column name 3": "{matching Parabola column name 3}",
      }
    }

Make sure to wrap the Parabola column names with "{ }". (Sometimes you won’t need the " " around the curly braces, but you’ll need to consult your Airtable API docs for that.

Remember to update the “Type” in the API Export depending on what you’re trying to do. If you’re creating new records, it would be POST, and if you’re updating records, it would be PATCH.

Let me know how that goes!

Hi - I would like to add a problem to this thread I’ve been having. My GET command works great but the PUT command doesn’t seem to work. I understand Airtable required specific formatting in the body.

So here’s what I’m finally using after much testing with either formats (including the Airtable API specification):

PUT endpoint

https://api.airtable.com/v0/base_idxxx/master/record_idxxxx \

The bearer token is correctly entered.

And the body:

–data {
“fields”: {
“Created”: {“Created”},
“First Name”: {“First Name”},
“Last Name”: {“Last Name”},
“Model”: {“Model”},
“Serial”: {“Serial”},
“Ticket”: {“Ticket”},
“RS_ID”: {“RS_ID”}
}
}

And the error message thrown back is JSON not properly formed, and I should use a JSON linter to Choose a JSON linter to check the syntax. I did that. Here’s what I get back:

Error: Parse error on line 1:
–data { “fields”:
^
Expecting ‘STRING’, ‘NUMBER’, ‘NULL’, ‘TRUE’, ‘FALSE’, ‘{’, ‘[’, got ‘undefined’

Also…I tried a few different body formats that might be more Airtable friendly, but same response:

{
“fields”: {
“Created”: “{Created}”,
“First Name”: “{First Name}”,
“Last Name”: “{Last Name}”,
“Model”: “{Model}”,
“Serial”: “{Serial}”,
“Ticket”: “{Ticket}”,
“RS_ID”: “{RS_ID}”
}
}

Lastly, what I find interesting is when I began working with this I was actually getting 404 messages. Now whatever I try the standard response is JSON not properly formed.

Whatever I’m doing is wrong and your help is greatly appreciated, as always.

Here’s the flow: https://parabola.io/flow/36580/

Hey Jeff - Did you maybe prep the Body outside of Parabola and paste it in? I think there was some added formatting that was messing with it.

Try pasting this snippet into your flow and replace your existing API Export with it: parabola:cb:dcea67f6be8146f7b9666e58ba92bdba

That snippet does not contain your token, app id, and record id from the snippet, so make sure to update those accordingly. Also, since you’re creating new records, you don’t need to specify the record ID in your endpoint URL. Your endpoint URL should be: https://api.airtable.com/v0/base_idxxx/master

Let me know how that goes!

I did paste it in. Guess that’s a no-no :wink: But if I write it manually

{
“fields”: {
“Created”: “{Created}”,
“First Name”: “{First Name}”,
“Last Name”: “{Last Name}”,
“Model”: “{Model}”,
“Serial”: “{Serial}”,
“Ticket”: “{Ticket}”,
“RS_ID”: “{RS_ID}”
}
}

…why wouldn’t that work?

I don’t understand how that snippet works but willing to try.

What I think you’re saying is transform the snippet to myBearerToken:appID:recordID and once updated… it lives in the Body field?

Sorry to confuse you! I don’t know how, but your quotation marks are actually “left double quotation marks”, instead of “quotation marks”. That’s what’s causing the JSON error.

Forget about my snippet, try pasting this into the body of your API Export:

{ "fields": {
 "Created": "{Created}",
"First Name": "{First Name}",
"Last Name": "{Last Name}",
"Model": "{Model}",
"Serial": "{Serial}",
"Ticket": "{Ticket}",
"RS_ID": "{RS_ID}"
}
}

Re-writing it into the body manually should fix the quotation marks as well. Let me know how that goes.

Good news - it updated so no malformed JSON error.

However it threw a 422 Unprocessable Entity Error
{
“error”: {
“message”: “Invalid request: parameter validation failed. Check your request data.”,
“type”: “INVALID_REQUEST_UNKNOWN”
}
}

It looks like you have a \ in your endpoint URL that’s causing the “invalid request” error since Airtable doesn’t recognize that endpoint. Try deleting that final \.

Originally I didn’t have the \ and it wasn’t working

That’s why I added it back in, but both ways it doesn’t work.

Just ran the flow again without the \ in the endpoint URL and getting a 422. Please advise, thanks.

You’re trying to create new records in your Airtable, right? Instead of PUT, use POST.

Hi Sachi - tried it…the run time took longer than 56 sec. this time, so I was hopeful - but it didn’t work. We’re back to invalid JSON. :thinking:

Got it. That would indicate that there’s some character in the data you’re trying to export that’s breaking the JSON formatting. Most likely a quote " or something like that.

Can you try dragging in a Magic Cleaning step and dropping it right in front of your API Export? It might take care of it. If that doesn’t work, try searching your data for special characters (like quotes) and just remove it or replace it entirely if you can.

Yup, it needed Magic Cleaning. Thanks for your help. :wink:

1 Like

Awesome. Glad to hear that solved it!

Yep, good thing. POST takes a very long time to run since all records are being removed and replaced. Wouldn’t it be better to use PUT so only the differences are added/deleted/updated?

PUT is destructive, which means it will remove any value that’s not specified. For updating existing records, we always recommend using PATCH instead of PUT when available.

For your use case, it sounds like you’ll have some records that already exist in Airtable that might need to be updated (PATCH) and some records that don’t yet exist that you’d like to create (POST).

Is that correct? Or, once a record already exists in Airtable, would no further updates be necessary?

If I’m understanding your use case correctly, I would optimize the flow by using the Airtable Import step to pull in the data that already exists in your Airtable table. This is how we’ll identify the records that already exist. You can use the Join step to match your existing data together with the Airtable data. The rows where there’s already an Airtable record ID can either be ignored or exported to Airtable via PATCH. The rows where there’s no record ID can be exported to Airtable via POST. So, in the end, you’ll have two separate API Exports to Airtable - one that updates existing records and another that creates new records.

2 Likes

Is there an easier way to export to airtable? I don’t write code but this would be great for my flow.

Or, is there someone that can help me do it?

Hi @Henry_Johnson,

Right now, the best way is to use our Send to an API step.

Feel free to share a link to your flow or email us at help@parabola.io. I’m happy to get your export settings up and running!