Views: 5682
Last Modified: 17.10.2024

The method gets department data

Revision: 18
To get information about the current API revision (platform version) – im.revision.get.

Parameters

Parameter Example Req. Description Revision
ID [51] Yes Department IDs 18
USER_DATA N No Download user data 18
  • If the USER_DATA = Y parameter is passed, manager data will downloaded additionally with the result.

Method call

JavaScript

BX24.callMethod('im.department.get', {ID: [51]}, function(result){
	if(result.error())
	{
		console.error(result.error().ex);
	}
	else
	{
		console.log(result.data());
	}
});

PHP

$result = restCommand('im.department.get', Array(
	'ID' => [51],
), $_REQUEST["auth"]);	

Example of response

{
	"result": [
		{
			"id": 51,
			"name": "New York branch",
			"full_name": "New York branch / Bitrix24"
			"manager_user_id": 11,
		}
	]
}    

Description of keys:

  • id – department ID
  • name – department abbreviated name
  • full_name – department full name
  • manager_user_data – manager data description object (unavailable, if USER_DATA != 'Y'):
    • id – user ID
    • name – user first and last name
    • first_name – user name
    • last_name – user last name
    • work_position – position
    • color – user color in 'hex' format
    • avatar – link to avatar (if empty, avatar is not specified)
    • gender – user gender
    • birthday – user birthday in the DD-MM format, if empty – not specified
    • extranet – extranet user attribute (true/false)
    • network – Bitrix24.Network user attribute (true/false)
    • bot – bot attribute (true/false)
    • connector – Open Channel user attribute (true/false)
    • external_auth_id – external authorization code
    • status – user status. Always displayed as online, even if user has set it as "Do not disturb". The "Do not disturb" status affects reception of notifications and isn't visible to other users
    • idle – date, when user is not using his/her PC, in ATOM format (if not specified, false)
    • last_activity_date – date of the last user action, in ATOM format
    • mobile_last_date – date of the last action inside mobile app, in ATOM format (if not specified, false)
    • absent – date, to which the user has a leave of absence, in ATOM format (if not specified, false)

Example of response when error occurs

{
    "error": "INVALID_FORMAT",
    "error_description": "A wrong format for the ID field is passed"
}

Description of keys:

  • error – error code
  • error_description – brief description of error

Possible error codes

Code Description
INVALID_FORMAT Invalid ID format is passed

Attention: restCommand function is used here for illustration purposes only. It is taken from the EchoBot example. You can send a REST command with your own function, or use the BX24.callMethod or bitrix24-php-sdk methods.





Courses developed by Bitrix24