Skip to content

Saving Multiple Objects

This API stores multiple objects in a data table with a single request. Consider the following example, it demonstrates an API call which saves two objects in the Person data table:

curl -X POST \  
  -H 'Content-Type: application/json' \  
  -d '[ \  
        { "name": "Joe", "age": 24 }, \  
        { "name": "Betty", "age": 34 } \  
      ]' \  
https://api.backendless.com/application-id/REST-api-key/data/bulk/Person

The result of running the sample above is two objects saved in the database:

bulk-create-result.zoom80

Method

POST

URL

https://api.backendless.com/<application-id>/<REST-api-key>/data/bulk/<table-name> 

where:

Argument                Description
<application-id> the ID of your application generated upon its creation. You can obtain the value in the Manage > App Settings section of the Backendless Console.
<REST-api-key> REST API key of your application. You can obtain the value in the Manage > App Settings section of the Backendless Console.
<table-name> name of the table where the objects need to be saved. If the table does not exist and Dynamic Schema Definition is enabled (it is turned on by default), Backendless creates the table and configures its schema to match the objects structure.

Request Headers

Content-Type:application/json  
user-token: value-of-the-user-token-header-from-login

where:

Argument                Description
Content-Type Must be set to application/json. This header is mandatory.
user-token Optional header. Contains a value returned by Backendless in a preceding user Login API call. If user-token is set in the request, the currently logged in user will be assigned to the ownerId property of the objects which are being saved.  Additionally, the operation will be executed with the security policy associated currently logged in user. This means all permissions associated with the user and the roles assigned to the user will be enforced by Backendless.

Return Value

The API returns a JSON array of object IDs for the objects created in the database. The order of  the objectId values in the response matches the order of the objects in the request.

The Backendless server implementation enforces the following rules:

  • All objects in the request must be of the same type.
  • Objects in the request may have different set of properties. If a column does not exist for a property, Backendless will dynamically create it, if the Dynamic Schema Definition configuration is enabled.
  • Objects in the request must not have objectId. If there is a value in the objectId property in a provided object, the object is ignored by the server.
  • Maximum number of objects in a single request is 100 for Backendless Cloud. It is configurable for Backendless Pro and Managed Backendless.
  • A request will be rejected by the server, if there is no Create permission granted to the user identity/roles associated with the request.