Views: 7311
Last Modified: 23.03.2022
The method gets user data
Revision: 18
Get information on the current API revision (platform version) – im.revision.get.
Parameters
Parameter |
Example |
Req. |
Description |
Revision |
ID |
5 |
No |
User ID |
18 |
AVATAR_HR |
N |
No |
Generate avatar in high resolution |
18 |
|
- If the
ID
key is not passed, current user data will be selected.
Method call
JavaScript
BX24.callMethod('im.user.get', {ID: 5}, function(result){
if(result.error())
{
console.error(result.error().ex);
}
else
{
console.log(result.data());
}
});
PHP
$result = restCommand('im.user.get', Array(
'ID' => 5,
), $_REQUEST["auth"]);
Example of response
{
"result": {
"id": 5,
"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,
"phones": {
"work_phone": "",
"personal_mobile": "",
"personal_phone": ""
}
}
}
Description of keys:
id
– user ID
name
– first and last user name
first_name
– user first name
last_name
– user last name
work_position
– position
color
– user color in 'hex' format
avatar
– link to avatar (if empty, the avatar is not specified)
avatar_hr
– link to avatar in high resolution (available only when a query with parameter AVATAR_HR = 'Y'
)
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 Bitrix24.Network (true/false
)
bot
– bot attribute (true/false
)
connector
– Open Channel user attribute (true/false
)
external_auth_id
– external authorization code
status
– user selected 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
)
departments
– department IDs
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
)
phones
– array of phone numbers: work_phone
– work phone, personal_mobile
– mobile phone, personal_phone
– personal phone number
Example of response when an error occurs
{
"error": "ID_EMPTY",
"error_description": "User ID can't be empty"
}
Description of keys:
error
– error code
error_description
– brief description of error
Possible error codes
Code |
Description |
ID_EMPTY |
User ID not passed |
USER_NOT_EXISTS |
User with indicated ID not found |
ACCESS_DENIED |
Current user does not have permissions to access the data |
|
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.