Skip to content

Updating Single Object

Method

PUT

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>/<objectId> 

where:

Argument                Description
<objectId> ID of the object to update assigned by Backendless in the create object operation. This part of the URL is optional. If the objectId value is not in the URL, it must be present in the request body.

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-tokenis set in the request, the operation will be executed with the security policy associated currently logged in user. This means all permissions associated with the user and roles assigned to the user will be enforced by Backendless.

Request Body

A JSON object to update in the database. The object may reference only the properties to update, but it is acceptable to include all properties of the object (including the ones to update). In this case, Backendless will update the entire object.

Response Body

A JSON representation of the updated 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 PUT  \  
-d "{\"name\":\"Bob\", \"age\":20 }" \  
-v https://xxxx.backendless.app/api/data/Person/6C77C11B-E9B3-EB14-FFA2-69F38CF48800

Notice the objectId value is put directly into the URL. The value is optional in the JSON body of the request if it included in the endpoint URL.

Codeless Reference

data_service_saving_object

where:

Argument                Description
table name Name of the data table where a record must be updated.
object A JSON object with properties that match the names of the table columns, these properties must contain new values for update operation. The objectId property and the corresponding value must be also included in theJSON object.
return result Optional parameter. When this box is checked, the operation returns the updated object.

Returns the updated JSON object.

Consider the following record stored in the employees data table:
data_service_example_update_2

The example below uses the objectId: "18AE9147-8016-412C-8E55-83B3188E153F" to find the record in the data table and update the value in the contactType column from "Personal" to "Work". To update more values in one query, specify the required number properties/column in the object and the new values.

data_service_example_update_1

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

data_service_example_update_3

Moreover, the operation described above has returned the updated JSON object:

data_service_example_update_4