Update User Object

Top  Previous  Next

Backendless supports the operation of user properties update for the logged in users. This operation is useful if an application needs to provide to the users the functionality for updating user profiles and registration properties. User must be logged in in order to update his registration properties.

Asynchronous Method:

The method call does not block - it returns immediately. The AsyncCallback argument receives either the response or the fault returned by the Backendless servers.

public void Backendless.UserService.update( BackendlessUser user, 
                                            AsyncCallback<BackendlessUser> );

where

user- an instance of the BackendlessUser class which contains property values to update the user account with.
callback- an object which receives either a return value or an error from the server. The return value from the server is an updated instance of the BackendlessUser class. The class of the callback object must implement the AsyncCallback<BackendlessUser> interface.

Synchronous Method:

public BackendlessUser Backendless.UserService.update( BackendlessUser user );

where

user- an instance of the BackendlessUser class which contains property values to update the user account with.

Errors:

The following errors may occur during the Update User Properties API call. See the Error Handling section for details on how to retrieve the error code when the server returns an error.

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.

Asynchronous Method:

Backendless.initApp( appId, secretKet, version ); // where to get the argument values for this call
Backendless.UserService.login( username, password, new AsyncCallback<BackendlessUser>()
{
 public void handleResponse( BackendlessUser user )
  {
    // user has been logged in, now user properties can be updated
    user.setProperty( "phoneNumber", "5551212" );
    Backendless.UserService.update( user, new AsyncCallback<BackendlessUser>()    
    {
      public void handleResponse( BackendlessUser user )
      {
        // user has been updated
      }
  
      public void handleFault( BackendlessFault fault )
      {
        // user update failed, to get the error code call fault.getCode()
      }
    });
  }

  public void handleFault( BackendlessFault fault )
  {
    // login failed, to get the error code call fault.getCode()
  }
});

Synchronous Method:

Backendless.initApp( appId, secretKet, version ); // where to get the argument values for this call
BackendlessUser user;

try
{
  user = Backendless.UserService.login( username, password );
}
catch( BackendlessException exception )
{
  // login failed, to get the error code, call exception.getFault().getCode()
}

try
{
  user.setProperty( "phoneNumber", "5551212" );
  user = Backendless.UserService.update( user );
}
catch( BackendlessException exception )
{
  // update failed, to get the error code, call exception.getFault().getCode()
}

 


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.: