Skip to content

Saving Single Object

Saving Data Object

Method

POST

Endpoint URL

The xxxx.backendless.app is a subdomain assigned to your application. For more information see the Client-side Setup section of this documentation.

https://xxxx.backendless.app/api/data/<table-name> 

where:

Argument                Description
<table-name> Name of the table where the object needs 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 object structure (properties).

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

Request Body

A JSON object to save in the database. Object properties must match the names of the table columns. The object must not have the objectId property.

Response Body

A JSON object saved in the database. The object will be assigned a unique objectId value that is included in the returned object.

Example

Important

Make sure to replace xxxx in the domain name in the sample request below to the one assigned to your application.

curl \  
-H Content-Type:application/json \  
-X POST  \  
-d "{\"name\":\"Bob\", \"age\":20}" \  
-v https://xxxx.backendless.app/api/data/Person

Codeless Reference

data_service_saving_object

where:

Argument                Description
table name Name of the data table where a new record must be saved.
object An object to save in the database. Object properties must match the names of the table columns. The object must not have the objectId property.
return result Optional parameter. When this box is checked, the operation returns the saved object with the objectId property.

Returns the saved object with the objectId property assigned by Backendless

Consider the following structure of the data table called employees:
data_service_example_saving_object_1

For demonstration purposes, the data table presented above has three custom columns: name, position, and phoneNumber. The objectId is a system column that contains unique identifiers of the records in the table. When a new record is saved to the table, the system assigns a unique objectId to it. The objectid is used in various operations as an access point to a specific record.

The example below saves a new JSON object to the employees data table:

data_service_example_saving_object_2

The result of this operation will look as shown below after the Codeless logic runs:

data_service_example_saving_object_3

The operation described above has returned the newly saved JSON object:

data_service_example_saving_object_4