Skip to main content

Error Code 422 - INVALID_REQUEST_MISSING_FIELDS

  • July 11, 2024
  • 8 replies
  • 165 views

Forum|alt.badge.img+2
I am using Voiceflow to retrieve data and send it to Airtable via the API. However, I keep encountering the above error despite my request appearing to be correctly formatted

This is in my body.

 

 

{ "records": [ { "fields": { "first": "test", "second": "test2", "tel": "000000000", "email": "test@test.com" } } ] }

 

 

 And in Airtable my table looks like this:

 

firstsecondtelemail

Any help would be good, thanks

8 replies

TheTimeSavingCo
Forum|alt.badge.img+31

Are you creating or updating records?


Forum|alt.badge.img+2
  • Author
  • New Participant
  • July 12, 2024

Are you creating or updating records?


I am trying to create an entry. 


sflorez
Forum|alt.badge.img+2
  • Participating Frequently
  • July 13, 2024

@James311it 

I think you are close, try using JSON.stringify() on javascript objects to construct your body payload when making a POST request via the Airtable API. 

for example using the body you posted it would look something like this:

//script above const data = [ { fields: { "first": "test", "second": "test2", "tel": "000000000", "email": "test@test.com" } } ] //example fetch call const res = await fetch(exampleURL, { method: 'POST', headers, body: JSON.stringify({ records: data }) })

 


TheTimeSavingCo
Forum|alt.badge.img+31

I am trying to create an entry. 


Hmm, could you provide a screenshot of the fields please?  I'd like to try replicating as, with all single line text fields your body works fine for me

Could I confirm you've set your content-type to JSON?  Maybe try setting typecast: true as well?


Forum|alt.badge.img+2
  • Author
  • New Participant
  • July 15, 2024

Hmm, could you provide a screenshot of the fields please?  I'd like to try replicating as, with all single line text fields your body works fine for me

Could I confirm you've set your content-type to JSON?  Maybe try setting typecast: true as well?


Hi,

The table is pretty straightforward, the only difference is I have two base documents. 
However I don't see why that would be a problem. 


Forum|alt.badge.img+2
  • Author
  • New Participant
  • July 15, 2024

Hi,

The table is pretty straightforward, the only difference is I have two base documents. 
However I don't see why that would be a problem. 


I have messed with the table's names, and that's why they are different from my post request. 

So the table is the original, but I removed the spaces and tried to make the table names shorter when troubleshooting. 


TheTimeSavingCo
Forum|alt.badge.img+31

Hi,

The table is pretty straightforward, the only difference is I have two base documents. 
However I don't see why that would be a problem. 


Thanks for the screenshot!  Just wanted to check what the field types were as that may be causing an issue!

I take it you've set your content-type to JSON and have tried setting typecast: true as well?  If so, I'd suggest opening a ticket with Airtable support directly!


Forum|alt.badge.img+2
  • Author
  • New Participant
  • July 16, 2024

Thanks for the screenshot!  Just wanted to check what the field types were as that may be causing an issue!

I take it you've set your content-type to JSON and have tried setting typecast: true as well?  If so, I'd suggest opening a ticket with Airtable support directly!


All the table fields are set to single-line text to simplify troubleshooting and avoid potential issues.

I am including a Content-Type header with the value application/json but am not using the typecast parameter set to true