Jul 02, 2020 03:27 PM
So, I’ve been trying to bulk add some fields to the table using the suggested code in the API:
base('GameRefereeSlots').create([
{
"fields": {
"GameCreation": "49",
"Fee": 10,
"Expenses": 10,
"Type": "Referee"
}
},
{
"fields": {
"GameCreation": "49",
"Fee": 10,
"Expenses": 10,
"Type": "Referee"
}
}
], function(err, records) {
if (err) {
console.error(err);
return;
}
records.forEach(function (record) {
console.log(record.getId());
});
});
This, however, does not work as it returns the following error:
message: “Invalid request: parameter validation failed. Check your request data.”
statusCode: 422
I’ve tried different alternatives by removing the “field” key and just having the plain object but it does not work. When adding only one of the options without it being in an array, i.e not batch adding, it works perfectly. Any thoughts on what could be the problem?
Jul 20, 2020 11:34 AM
I haven’t been able to reproduce this problem. I created a table named “GameRefereeSlots” with the following fields:
I inserted the following two lines at the top of the script you shared (replacing “my key here” and “my Base ID here” with the appropriate values):
var Airtable = require('../airtable');
var base = new Airtable({apiKey: 'my key here'}).base('my Base ID here');
When I ran that script, it successfully created both records and printed their IDs to standard output.
Can you share the version of airtable.js that you are using?
Dec 27, 2020 06:24 AM
I was having the same issue with a batch insert. I copied the example from the Airtable API docs and received the “Invalid request: parameter validation failed. Check your request data. statusCode: 422". I’ve spent several hours trying to debug it.
After reading this and wonder what version my airtable.js is, I decided to update airtable.browser.js and now my code is working. The example code I started from must have been an older version.
The error isn’t very descriptive, but I think the lesson here is first thing to do is very your airtable.js is the latest from https://github.com/Airtable/airtable.js