Batch adding not working

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?

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.

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?