Support Topics Documentation Slack YouTube Blog

Error with Bulk Create Upload

Hi Folks.

I want to allow people to upload a CSV file to my portal, convert that to a JSON value and then bulk upload that to the table. I have the importer working, with the following output to a variable:

  var OutputData = JSON.stringify(result.validData, null, 2)
  console.log("This is Output Data \n" + OutputData)

This is Output Data
[
{
“Open”: “A First Test”,
“Location”: “Test 1”,
“Details”: “Test 1”,
“Notes”: “Test 1”
},
{
“Open”: “A Second Test”,
“Location”: “Test 2”,
“Details”: “Test 2”,
“Notes”: "Test 2 "
}
]

Which (as far as i tell) matches the required format for the bulkUpload function. However when i run the bulk upload i get the following error:

Backendless.Data.of("Testing_Table").bulkCreate(OutputData).then(function(result) {
console.log("Items Saved")}).catch(function(error) { 
console.log(error)})

Error: Invalid bulkCreate argument. The first argument must contain only array of objects.

Any Ideas at all? As i’m properly stumped!

Hi Alex,

The object you pass into the bulkCreate call is obtained from the stringify() function, there it is a string and not an array. Instead, try passing result.validData into bulkCreate.

Cheers,
Mark

Its always the little things that you just miss… Thank you very much, that’s done the trick nicely!