Update User

Purpose

To update the details of a user of your organization.

Request Details

Request URL

https://www.zohoapis.com/bigin/v1/users
 

Scope

scope=ZohoBigin.users.{operation_type}

Possible operation types

ALL - Full access to users
UPDATE - Update user data

Note

You can update only one user's details per PUT request.

Sample Request

Copiedcurl "https://www.zohoapis.com/bigin/v1/users"
-H "Authorization: Zoho-oauthtoken 1000.8cb99dxxxxxxxxxxxxx9be93.9b8xxxxxxxxxxxxxxxf"
-d "@updateuser.json"
-X PUT
Copiedimport java.util.List;

import com.zoho.crm.library.api.APIConstants;
import com.zoho.crm.library.api.response.APIResponse;
import com.zoho.crm.library.api.response.BulkAPIResponse;
import com.zoho.crm.library.common.ZCRMEntity;
import com.zoho.crm.library.crud.ZCRMOrgTax;
import com.zoho.crm.library.crud.ZCRMTax;
import com.zoho.crm.library.setup.metadata.ZCRMOrganization;
import com.zoho.crm.library.setup.restclient.ZCRMRestClient;
import com.zoho.crm.library.setup.users.ZCRMProfile;
import com.zoho.crm.library.setup.users.ZCRMRole;
import com.zoho.crm.library.setup.users.ZCRMUser;
import com.zoho.oauth.client.ZohoOAuthClient;
import com.zoho.oauth.contract.ZohoOAuthTokens;

public class Org{
	public Org() throws Exception{
		ZCRMRestClient.initialize();
	}
	public void updateUser() throws Exception{
		ZCRMRestClient client = ZCRMRestClient.getInstance();
		ZCRMUser user=ZCRMUser.getInstance(554023000000691003L);//554023000000691003L is user id
		user.setFirstName("firstname");
		user.setFullName("firstname lastname");
		user.setLastName("lastname");
	
		ZCRMOrganization org=client.getOrganizationInstance();
		APIResponse response=org.updateUser(user);
		System.out.println("HTTP status code "+response.getStatusCode());
		System.out.println("Status "+response.getStatus());
		System.out.println("message "+response.getMessage());
	}
	public static void main(String[] args) throws Exception {
		Org obj=new Org();
		obj.updateUser();
	}
}
Copied# Update user
# -----------
def update_user(self):
    try:
        user_ins = zcrmsdk.ZCRMUser.get_instance(554023000000691003, 'Boyle') # user id and user name
        user_ins.first_name = "Patricia"
        resp = zcrmsdk.ZCRMOrganization.get_instance().update_user(user_ins)
        print(resp.status_code)
        print(resp.message)
        print(resp.code)
        print(resp.status)
        print(resp.details)
        print(resp.data)
    except zcrmsdk.ZCRMException as ex:
        print(ex.status_code)
        print(ex.error_message)
        print(ex.error_code)
        print(ex.error_details)
        print(ex.error_content)
Copied<?php
use zcrmsdk\crm\setup\restclient\ZCRMRestClient;
use zcrmsdk\crm\setup\users\ZCRMProfile;
use zcrmsdk\crm\setup\users\ZCRMRole;
use zcrmsdk\crm\setup\users\ZCRMUser;
require 'vendor/autoload.php';
class Org{
    public function __construct()
    {
            $configuration = array("client_id"=>{client_id},"client_secret"=>{client_secret},"redirect_uri"=>{redirect_url},"currentUserEmail"=>{user_email_id});
            ZCRMRestClient::initialize($configuration);
    }
    public function updateUser(){
        $orgIns = ZCRMRestClient::getOrganizationInstance(); // to get the organization instance
        $user=ZCRMUser::getInstance("{user_id}", "{user_name}");//to get the user instance
        $user->setId("{user_id}");//to set the id of the user
        $user->setFax("321432423423");//to set the fax number of the user
        $user->setMobile("4234234232");//to set the mobile number of the user
        $user->setPhone("2342342342");//to set the phone number of the user
        $user->setStreet("sddsfdsfd");//to set the street name of the user
        $user->setAlias("test");//to set the alias of the user
        $user->setWebsite("www.zoho.com");//to set the website of the user
        $user->setCity("chennai");//to set the city of the user
        $user->setCountry("India");//to set the country of the user
        $user->setState("Tamil nadu");//to set the state of the user
        $user->setZip("6000010");//to set the zip code of the user
        $responseIns=$orgIns->updateUser($user);//to update the user
        echo "HTTP Status Code:".$responseIns->getHttpStatusCode(); //To get http response code
        echo "Status:".$responseIns->getStatus(); //To get response status
        echo "Message:".$responseIns->getMessage(); //To get response message
        echo "Code:".$responseIns->getCode(); //To get status code
        echo "Details:".json_encode($responseIns->getDetails());
    }
}
    $obj =new Org();
    $obj->updateUser();
Copied/** To update user */
public void UpdateUser()
{
    ZCRMUser user = ZCRMUser.GetInstance(554023000000691003);//user id
    ZCRMOrganization OrgInstance = ZCRMRestClient.GetInstance().GetOrganizationInstance();
    user.Country = "US";
    user.Role = ZCRMRole.GetInstance(554023000000015969, "Manager");
    user.City = "Chennai";
    user.Street = "street";
    user.Alias = "alias";
    user.State = "state";
    user.Fax = "fax";
    user.CountryLocale = "en_US";
    user.FirstName = "TEST";
    user.Zip = "zip";
    user.Website = "https://www.zoho.com";
    user.Profile = ZCRMProfile.GetInstance(554023000000015975, "Standard");
    user.Mobile = "95851535";
    user.Phone = "0980911111";
    user.DateOfBirth = "1995-05-05";
    user.DateFormat = "MM/dd/yyyy";

    user.SetFieldValue("FieldApiName", "FieldApiValue");
    APIResponse response = OrgInstance.UpdateUser(user);
    Console.WriteLine(response.HttpStatusCode);
    Console.WriteLine(response.Status);
    Console.WriteLine(response.ResponseJSON);
    Console.WriteLine(response.Message);
    Console.WriteLine(JsonConvert.SerializeObject(response));
    Console.WriteLine("\n\n\n");
}
Copieduser1 = Map();
user1.put("id", "692969000000282009");
user1.put("last_name", "B");

users_list = List();
users_list.add(user1);

params = Map();
params.put("users", users_list);

response = invokeurl
[
	url: "https://www.zohoapis.com/crm/v2/users"
	type: PUT
	parameters: params.toString()
	connection:"crm_connection"
];
info response ;

In the request, "@updateuser.json" contains the sample input data.

Request JSON
  • idstring, mandatory

    Specify the record ID of the user you want to update.

Note
  • You can also pass the record ID in the request. Example: {{api-domain}}/bigin/v1/users/{{record_id}}

  • Refer to Get User API to obtain the record ID of the user.

  • You cannot update a deactivated user.

  • You cannot deactivate the primary contact of your organization. To deactivate the primary contact, you must assign another user as the new primary contact of your organization and then deactivate the old primary contact.

  • To activate or deactivate a user, use the key status in the input with the value as either active or inactive, respectively.

  • You cannot change the time zone of another user. You can only change the time zone of your own user record. Refer to Fields Metadata API to know the values of the key "time_zone".

  • You must use only Field API names in the input. You can obtain the field API names from Fields metadata API (the value for the key “api_name” for every field).

Sample Input

Copied{
  "users": [
    {
      "id": "554023000000691003",
      "phone": "123456789",
      "email": "newtocrm@zoho.com",
      "dob": "1990-12-31",
      "role":"79234000000031154",
      "profile":"79234000000031157",
      "country_locale": "en_US",
      "time_format": "HH:mm",
      "time_zone": "US/Samoa",
      "status": "active"
    }
  ]
}

Possible Errors

  • INVALID_DATAHTTP 200

    Cannot update the time_zone of another user
    Resolution: You cannot update the time zone of another user.

  • AUTHORIZATION_FAILEDHTTP 400

    Either trial has expired or user does not have sufficient privilege to perform this action
    Resolution: Contact your system administrator.

  • INVALID_DATAHTTP 400

    Invalid data
    Resolution: The input you have specified is invalid

  • INVALID_DATAHTTP 400

    Invalid data
    Resolution: Unclosed Script tags found in signature. Specify valid script tags

  • CANNOT_UPDATE_DELETED_USERHTTP 400

    Deleted user cannot be updated
    Resolution: You cannot update a deleted user.

  • INVALID_REQUESTHTTP 400

    Re-invite is not allowed for a confirmed user
    Resolution: You cannot re-invite a confirmed user.

  • EMAIL_UPDATE_NOT_ALLOWEDHTTP 400

    Cannot update email of a confirmed Bigin User
    Resolution: You cannot update the email of a confirmed user.

  • DUPLICATE_DATAHTTP 400

    User with same email id exists
    Resolution: You are trying to specify a duplicate value for a unique field. Ensure that you specify unique and valid email IDs for all the users.

  • ID_ALREADY_DEACTIVATEDHTTP 400

    User is already deactivated
    Resolution: The user you are trying to deactivate is already deactivated.

  • INVALID_REQUESTHTTP 400

    Primary Contact cannot be deactivated
    Resolution: You cannot deactivate a primary contact.

  • ID_ALREADY_ACTIVEHTTP 400

    User is already active
    Resolution: The user you are trying to activate is already active.

  • FEATURE_PERMISSIONHTTP 400

    Share among Subordinates Feature is not available
    Resolution: The share among the subordinated feature is not available for your account. Contact your system administrator.

  • AUTHORIZATION_FAILEDHTTP 405

    Profile and Role cannot be Updated by the user
    Resolution: The current user does not have permission to update the profile and role of another user. Contact your system administrator.

Sample Response

Copied{
  "users": [
    {
      "code": "SUCCESS",
      "details": {
        "id": "554023000000691003"
      },
      "message": "User updated",
      "status": "success"
    }
  ]
}