Help

Re: Batch adding not working

1364 0
cancel
Showing results for 
Search instead for 
Did you mean: 
YesRef_Develope
4 - Data Explorer
4 - Data Explorer

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?

2 Replies 2
Mike_Pennisi
7 - App Architect
7 - App Architect

I haven’t been able to reproduce this problem. I created a table named “GameRefereeSlots” with the following fields:

  • GameCreation (type: Single line text)
  • Fee (type: Number)
  • Expenses (type: Number)
  • Type (type: Single line text)

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?

James_M
4 - Data Explorer
4 - Data Explorer

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