Start a new topic
Answered

API Console POST

Hi,


I am having trouble using the API Console to POST an array of Collection entities. For example the following JSON body will work:

Request

 

POST /appdata/kid_HypvcKoTx/SampleItem HTTP/1.1
Host: baas.kinvey.com
Content-Type:application/json
Authorization: Kinvey 22f2b632-9b96-40ea-a789-152fb7fcbae8.fjd2yV9ABMNDmnwC3grqvOJnXRzEoSQhTXxwL6eMsdE=
X-Kinvey-API-Version: 3

 {
   "workorder": 123981238,
    "AssetName": "mollit",
    "AssetType": 4,
    "SMU": 24148,
    "OilChanged": false,
    "Component": "elit aliquip",
    "BottleBarcode": 4132608157600208,
    "EmployeeName": "Meyer Mccray",
    "SampleType": "Static"
 }

Response

HTTP/1.1 201 Created
Content-Type: application/json
Location: https://baas.kinvey.com/appdata/kid_HypvcKoTx/SampleItem/594132350ce8f3467134483c
X-Kinvey-API-Version: 3
X-Kinvey-Request-Id: 3baf0356418e4913b452160144b60d8a
X-Powered-By: Express

{
    "workorder": 123981238,
    "AssetName": "mollit",
    "AssetType": 4,
    "SMU": 24148,
    "OilChanged": false,
    "Component": "elit aliquip",
    "BottleBarcode": 4132608157600208,
    "EmployeeName": "Meyer Mccray",
    "SampleType": "Static",
    "_acl": {
        "creator": "593d1fb1f7b5c78401a66444"
    },
    "_kmd": {
        "lmt": "2017-06-14T12:55:17.527Z",
        "ect": "2017-06-14T12:55:17.527Z"
    },
    "_id": "594132350ce8f3467134483c"
}


However if I want to POST an array of objects it doesn't work:

POST /appdata/kid_HypvcKoTx/SampleItem HTTP/1.1
Host: baas.kinvey.com
Content-Type:application/json
Authorization: Kinvey 22f2b632-9b96-40ea-a789-152fb7fcbae8.fjd2yV9ABMNDmnwC3grqvOJnXRzEoSQhTXxwL6eMsdE=
X-Kinvey-API-Version: 3

[{
    "workorder": 31298,
    "AssetName": "mollit",
    "AssetType": 4,
    "SMU": 24148,
    "OilChanged": false,
    "Component": "elit aliquip",
    "BottleBarcode": 4132608157600208,
    "EmployeeName": "Meyer Mccray",
    "SampleType": "Static"
  },
 {
   "workorder": 123981238,
    "AssetName": "mollit",
    "AssetType": 4,
    "SMU": 24148,
    "OilChanged": false,
    "Component": "elit aliquip",
    "BottleBarcode": 4132608157600208,
    "EmployeeName": "Meyer Mccray",
    "SampleType": "Static"
 }
]

Response

HTTP/1.1 400 Bad Request
Content-Type: application/json
X-Kinvey-Request-Id: 5b9a79b96b88492db45846759e91b75a
X-Powered-By: Express

{
    "error": "JSONParseError",
    "description": "Unable to parse the JSON in the request",
    "debug": "incoming request body is not an [object Object]: [object Array]"
}

Best Answer
Michael,

Kinvey allows only a single entity to be created at a time. For bulk upload, see the CSV/JSON import feature on the Kinvey console (navigate to the collection, click Settings, then click Import Data). Check Datastore Create.

 

Thanks,

Pranav

Kinvey

1 Comment

Answer
Michael,

Kinvey allows only a single entity to be created at a time. For bulk upload, see the CSV/JSON import feature on the Kinvey console (navigate to the collection, click Settings, then click Import Data). Check Datastore Create.

 

Thanks,

Pranav

Kinvey

Login or Signup to post a comment