You are not logged in.
Hi All
I'm trying to get a users ID when searching the API for an email address, but it doesn't return the ID.
The search I am using is:
https://myserver/apirest.php/search/User?criteria[0][field]=5&criteria[0][searchtype]=contains&criteria[0][value]=" + requester +"&forcedisplay=[1,2,5,9,13,14,80]"
However with or without forced display it won't return field 2, the ID.
Is there another way to get the users ID by querying the email address?
GLPI V9.2.1
Many thanks
David
Offline
Maybe this is a issue of this version.
I already used the 9.2.1, but it's have many bugs.
Offline
try this url : (it works with glpi 9.5.4)
$url="/search/User?criteria[0][field]=5&criteria[0][searchtype]=contains&criteria[0][value]=".myemail."&forcedisplay[0]=1&forcedisplay[1]=2&forcedisplay[2]=5&forcedisplay[3]=9&forcedisplay[4]=14&forcedisplay[5]=80";
edit : moved to API section
Trouver la panne avant de réparer...
GLPI10.0.16 (ubuntu 22.04 PHP8.1 Mariadb10.6 ) plugins : comportements 2.7.3 reports 1.16.0 formcreator 2.13.9, datainjection 2.13.5 fields 1.21.9
Offline
try this url : (it works with glpi 9.5.4)
$url="/search/User?criteria[0][field]=5&criteria[0][searchtype]=contains&criteria[0][value]=".myemail."&forcedisplay[0]=1&forcedisplay[1]=2&forcedisplay[2]=5&forcedisplay[3]=9&forcedisplay[4]=14&forcedisplay[5]=80";
edit : moved to API section
Fantastic, that worked perfectly. Many thanks for your help.
Offline
This code is perfect, however when I am trying to search the user based on name example user login is 3000022 but it doesn't work, if I replace 3000022 with email address then it works,
any idea how to get the user ID # by searching the name/login_name ?
I am trying to get
// GET USER ID
$name = "3000022";
$api_url="http://192.168.252.102/apirest.php";
$url = $api_url . "/search/User?criteria[0][field]=1&criteria[0][searchtype]=contains&criteria[0][value]=^". $name. "$&forcedisplay[0]=2";
//$url=$api_url . "/listSearchOptions/User";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
//curl_setopt($ch, CURLOPT_POSTFIELDS,$input);
$json = curl_exec($ch);
curl_close($ch);
$obj = json_decode($json, true);
$agentbadge = $obj['data']['0']['2'];
echo "AgentBadge: $agentbadge";
Online
Offline