Saving Data Objects

Top  Previous  Next

This operation persists an object in a table. If the table does not exist, it is automatically created based on the name of the class of the object or the special ___class property in the object. When Backendless creates a data table, the table schema will contain a column for every property of the persisted object.

 

Saving Data Object

Method:

POST

URL:

https://api.backendless.com/<version>/data/<table-name>

where:

<version>- name of the application's version. Application versions can be managed using Backendless Console. Login to the console, select an application, click Manage, then Versioning. Backendless automatically creates version "v1" for any new application.
<table-name>- name of the table where the object needs to be saved. If the table does not exist, Backendless creates the table and configures its schema to match the object structure (properties).

Request Headers:

application-id: app-id-value
secret-key: secret-key-value
user-token: value-of-the-user-token-header-from-login // to set ownerId value
Content-Type:application/json
application-type: REST

where:

application-id- the ID of your application generated upon its creation. You can find this header in the Manage > App Settings section of the Backendless Console. This header is mandatory. Please refer to the Setup section for information on how to obtain the values for the header.
secret-key - the key of your application generated upon its creation. You can find this header in the Manage > App Settings section of the Backendless Console. This header is mandatory. Please refer to the Setup section for information on how to obtain the values for the header.
user-token - the ID of the user object that sends the request. If the value is set, it will be assigned to the ownerId property of the object to facilitate the object retrieval according to "Owner Policy." This header is optional.
Content-Type- the static value, should be set to application/json. This header is mandatory.
application-type- the static value, should be set to REST. This header is mandatory.

Sample Request Body:

{
 "name" : "James Bond",
 "age" : 33,
 "phoneNumber" : "+44123456789",
}

Sample Response Body:

{
 "name" : "James Bond",
 "age" : 33,
 "phoneNumber" : "+44123456789",
 "updated" : null,
 "created" : "02/04/2014 19:40:10 GMT+0000",
 "ownerId" : null | <user-id>,
 "objectId" : "28325E9F-2DED-D3CA-FFC6-C76911AFBB00",
 "___class" : "Person"
}

where:

updated- special property generated by Backendless which contains the timestamp when the object was last updated. For new objects, the value of the property is null.
created- similar to 'updated', but contains the timestamp showing when the object was initially created.
ownerId- when the object is created by an authenticated user, this property contains the id of the currently logged in user object.
objectId- unique id (GUID) assigned to the object.
___class- contains the name of the table where the object is stored. This is the same value as the <table-name> in the URL.

Example:

curl
-H application-id:application-id-value-from-console
-H secret-key:secret-key-value-from-console
-H Content-Type:application/json
-X POST
-d "{\"name\":\"Bob\", \"age\":20}"
-v https://api.backendless.com/v1/data/Person

 

 


Please let us know how we can improve the documentation by leaving a comment. All technical questions should be posted to the Backendless Support forum. We do not respond to the technical questions on the documentation pages.: