DocumentDB: bulkInsert Stored Proc - Getting 400 Error on Array/JSON issue

192
December 11, 2017, at 9:08 PM

I'm simply trying to execute the standard example bulkInsert sproc for documentDB API and I can't seem to pass it an array of objects. I always get 400 errors despite the documentation giving clear direction to send an array of objects .. very frustrating.

Bad Request: The document body must be an object or a string representing a JSON-serialized object.

bulkInsert.js: https://github.com/Azure/azure-documentdb-js-server/blob/master/samples/stored-procedures/BulkImport.js

My Code (using documentdb-util for async):

execProc(docs, insertProc);
async function execProc(docs, insertProc){
    let database = await dbUtil.database('test');
    let collection = await dbUtil.collection(database, 'test');
    let procInstance = await dbUtil.storedProcedure(collection, insertProc);
    try{
        let result = await dbUtil.executeStoredProcedure(procInstance, docs);
        console.log(result);
    } catch(e){
        console.log(e.body)
    }  
}

Header

Object {Cache-Control: "no-cache", x-ms-version: "2017-11-15", User-Agent: "win32/10.0.16299 Nodejs/v8.9.0 documentdb-nodejs-s…", x-ms-date: "Mon, 11 Dec 2017 07:32:29 GMT", Accept:"application/json" authorization: myauth Cache-Control:"no-cache" Content-Type:"application/json" User-Agent:"win32/10.0.16299 Nodejs/v8.9.0 documentdb-nodejs-sdk/1.14.1" x-ms-date:"Mon, 11 Dec 2017 07:32:29 GMT" x-ms-version:"2017-11-15"

Path "/dbs/myDB/colls/myColl/sprocs/myBulkInsert"

Params

Array(3) [Object, Object, Object] length:3

0:Object {id: "0001", type: "donut", name: "Cake", …}

1:Object {id: "0002", type: "donut", name: "Raised", …}

2:Object {id: "0003", type: "donut", name: "Old Fashioned", …}

[{
    "id": "0001",
    "type": "donut",
    "name": "Cake",
    "ppu": 0.55
},
{
    "id": "0002",
    "type": "donut",
    "name": "Raised",
    "ppu": 0.35
},
{
    "id": "0003",
    "type": "donut",
    "name": "Old Fashioned",
    "ppu": 0.25
}]
READ ALSO
Open skype chat

Open skype chat

I am using skype href to open skype chat, but chrome is asking choose application !

261
Nouislider setting range from variable

Nouislider setting range from variable

I'm using the nouislider (https://refreshlesscom/nouislider/) and I want to set up the range values from variables

248
Camera clicked images sent to rails server through the iPhone mobile browser are offset by particular dimensions

Camera clicked images sent to rails server through the iPhone mobile browser are offset by particular dimensions

I am dealing with a problem where images clicked through an iPhone camera and uploaded through the mobile browsers to a rails backend have a portion cutoff and are seemingly pushed out

128