Views: 953 (Data available since 06.02.2017)

The method searches for users

Revision: 19
Get information on the current API revision (platform version) – im.revision.get.

Parameters

Parameter Example Req. Description Revision
FIND John Yes Search phrase 19
BUSINESS N No Search among users with business tool access 19
AVATAR_HR N No Generate avatar in high resolution 19
OFFSET 0 No Offset of user selection 19
LIMIT 10 No User selection limit 19
  • Search is performed by the following fields: Name, Last name, Position, Department.
  • The method supports standard Bitrix24 REST API pagewise naviagation. Additionally, it can build navigation via the OFFSET and LIMIT parameters.

Method call

JavaScript

BX24.callMethod('im.search.user.list', {
	FIND: 'John'
}, function(result){
	if(result.error())
	{
		console.error(result.error().ex);
	}
	else
	{
		console.log('users', result.data());
		console.log('total', result.total());
	}
});

PHP

$result = restCommand('im.search.user.list', Array(
	'FIND' => 'Евгений'
), $_REQUEST["auth"]);	

Example of response

{    
	"result": {
		1: {
			"id": 1,
			"name": "John Harrington",
			"first_name": "John",
			"last_name": "Harrington",
			"work_position": "",
			"color": "#df532d",
			"avatar": "http://192.168.2.232/upload/resize_cache/main/1d3/100_100_2/Harrington.png",
			"gender": "M",
			"birthday": "",
			"extranet": false,
			"network": false,
			"bot": false,
			"connector": false,
			"external_auth_id": "default",
			"status": "online",
			"idle": false,
			"last_activity_date": "2018-01-29T17:35:31+03:00",
			"desktop_last_date": false,
			"mobile_last_date": false,
			"departments": [
			  50
			],
			"absent": false
		}
	},
	"total": 1
}      

Description of keys:

  • 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 – selected user status
  • 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)
  • desktop_last_date – date of the action in the desktop 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": "FIND_SHORT",
    "error_description": "Too short a search phrase."
}

Description of keys:

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

Possible error codes

Code Description
FIND_SHORT Search phrase is top short, search is possible with three symbols minimum.

Attention! The method is specified with using of the restCommand function. This method is used to send data in Bitrix24 and is available in the EchoBot example as well as in this article. You can use your own function or BX24.callMethod, or bitrix24-php-sdk JavaScript methods.





Courses developed by «Bitrix», Inc.