Update User Object¶
Description¶
User property values of the logged in users can be updated with an API operation described below. This operation is useful if an application needs to provide to the users the functionality for updating user profiles and registration properties. A user must be logged in to update his registration properties.
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/users/<user-id>
where:
Argument | Description |
---|---|
<user-id> |
a value of the "objectId" property received in the response for the Login operation. |
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 |
a value returned by Backendless in the response for the preceding Login operation. If user-token is set in this request, the currently logged in user will be assigned to the ownerId property of the user object which is being updated. This is done to facilitate the user object retrieval according to "Owner Policy." This header is optional. |
Request Body¶
{
"email" : value,
"password" : value,
...
}
Response Body¶
The user object containing updated user data. The object has the values for all the properties stored in the Users data table.
Example¶
The example below updates the value of the "phoneNumber"
property in the user object to "5551212"
and sends it to the server.
Important
Make sure to replace xxxx in the domain name in the sample request below to the one assigned to your application.
curl
-H user-token:[`value-of-user-token-from-login`](users_login.md#response-body)
-H Content-Type:application/json
-X PUT
-d '{"phoneNumber":"5551212"}'
-v
https://xxxx.backendless.app/api/users/value-of-id-from-login
Errors¶
When the server-side reports an error, it returns a JSON object in the following format:
{
"message":error-message,
"code":error-code
}
The following errors may occur during the Update User Properties API call.
Error Code |
Description |
---|---|
2002 |
Version is disabled or provided wrong application info (application id or secret key) |
3018 |
The property marked as "identity" is being updated and another user already has the specified value which must be unique. |
3024 |
General "update registration" error. Error message should contain additional details. |
3028 |
User is not logged in. |
3029 |
Cannot modify properties of another user. Returned when one user is logged and the call attempts to modify properties of another user. |
3030 |
Unable to locate user account - invalid user id. |
3031 |
A new "dynamic" property is being added, but dynamic property definition is disabled. |
3045 |
Required properties in the provided object do not contain values. |
Codeless Reference¶
Returns the user object containing updated user data. The object has the values for all the properties stored in Users data table.
Consider the following record in the Users
data table:
The example below logs in as "alice@yourmail.com"
to obtain the user-token. Then it updates the contents of the email
and address
columns in the Users
data table. Note that you have to use the objectId
in the operation to update the user.
The result of this operation is the new email "alice@newmail.com"
and address "27 Rose Street"
.