Issues Passing Data To Airtable through the POST request

I’m currently trying to take user entered data in the application I’m building and pass it into a table created in my airtable workspace. I am able to successfully get the collection of data and a single record in order to build my schema for the data variables. However when I go to test the POST command I get a 422 error message returned
I’ve also noticed that I can set a data variable in the page that will be collecting user info and creating a record in the air table data base, and set each input field to the proper schema (or property) that corresponds with the info collected on that input field. However when I test the app out and enter in some data through preview I do not see the data pass through to airtable. I’m not sure what I’m currently doing wrong so I’ll attach here the error message and how my post command is currently configured. 2020-06-11 14_57_51

Can you show how your Test and Schema tabs look? You need to configure the POST body structure in the Schema tab for the correct data to be passed to the backend.

Here are images of my test and schema pages. The schema is being taken from the same schema set by the GET pathway, as you can see its toggled on the schema page there. On the test page this reflects by having an object that is an ID, the fields object which has all my records categories in it, and then below it is an object defined as created time. When you say the post body structure, what do you mean?


If you’re creating a new record then Airtable generates the ID for you (if you are updating an existing record, you need to use PUT), and for POST to work you need to send an object called “fields” with your data inside it matching the schema of your table.

I hope that helps.

Oli

Screenshot 2020-06-12 at 19.02.31

Thank you Oli, setting up my schema this way gets the test to return successfully and I can see the test entry getting applied to the database. The issue I’m having now is getting the input in the input fields to post to airtable from using the app itself. I basically have five input fields set up and a data variable pulling from this data resource. Each input field’s value is set to the property of its corresponding schema in the data source. at the bottom of the page I have a button that has the “create record” logic plugged into it and it is supposed to create a record for what has been entered in each input field, but I’m not getting any output to airtable. Anyone have any thoughts? image image

For the data linking in the “Create record” you could check if changing the from direct “data field” link to “formula link” e.g. data.Airtable.fields.AGE will work? There was a bug where nested data variables were not linking via linking to them via data selection but were working fine when just changed to formula.

Hi Bryce,

The first thing I would do (I’m sure you’ve done it already - but just in case) is to check with the debugger that your local data variable is being updated in the way that you want.

What I did with my app, was to use page Variables to hold the data that that the user was adding in the app, and then write those page variables to my airtable backend using ‘create record’.

What sort of variable are you using? An array or an object? I only ask, because you can’t just use the . notation to get data from an array, you have to use a formula (lookup).

I have attached a screenshot of a ‘create record’ logic element that worked in my app.

I hope that helps.

Thanks Greg,

This issue is also present on at least some uses of data taken from repeated list items and is solved as you suggested.

Hello @Oli_Clark, can you explain in a more detailed way how you “send” an object called fields with your data inside it?

I am having the same 422 error problem and I can’t figure it out how to solv it. It would be perfect if you could send more prints on how to do that.

Thank you in advance.

1 Like

To make a POST request (which is send data) you need to be sure that your post Schema matches what you see in your Airtable API description.

There are 2 ways of sending data in POST to Airtable:

  • multiple records:
    {“records”: [{object},{object2},{object3}]}
  • single record
    {object}

Based on the above you need to set your schema accordingly to be able to bind variables.

When I refer to {object} above it represents a set of data for Airtable record and it should have the following structure
{
“fields”: {
“Name”: “John”,
“Notes”: “Notes about John”,
“Column3”: “en”,
“Column4”: “English”
}

Hi Oli,

How did you set this up?

Hi Shimon,

this is all a long time ago and I’ve moved on to hosting my data with sashido now, but the basic principle is that in the Data tab, you set up your REST api integration ensuring that the schema for the “Create Record” matches your schema in airtable. (as i said before, it all needs to be in an object called “fields”). Once you’ve done that then using the create record flow function you should just be able to create an entry using data from your app.

Since last year I think that AppGyver have made some new tutorials - have a look for them…

Oli