1

I am referring : https://learn.microsoft.com/en-us/graph/api/user-get?view=graph-rest-1.0&tabs=http and this url : https://graph.microsoft.com/v1.0/me -- works fine.

and trying to get the required user details.

My question is, how to get the field details (sbx,cn,uid,mail,jobtitle) for any specific user ID?

The idea is to find any user details ( any field above, if not all) using MS graph API.

I tried this :

     https://graph.microsoft.com/v1.0/ID1234?$select=sbx,cn,uid,mail,jobtitle

However, getting error:

      "error": { 
             "code" : "BadRequest",
             "message":"Resource not found for the segment 'ID1234'.",
              --------------------------------------------
              -------------------------------------------
               }

What is the correct way of getting user details using MS graph API ? Any example please?

Thanks

AskMe
  • 2,495
  • 8
  • 49
  • 102
  • Could you specifiy what do you mean by sbx, cn and uid? – user2250152 Apr 27 '21 at 10:39
  • Its the details people usually get while trying to find details from LDAP. cn = common name, uid is user id. https://stackoverflow.com/questions/18756688/what-are-cn-ou-dc-in-an-ldap-search – AskMe Apr 27 '21 at 11:01
  • Could you pls give me a mark if you feel my post is helpful to you? And if you met further error on it, pls feel free to update here. Thanks in advance : ) – Tiny Wang Apr 27 '21 at 14:16

1 Answers1

2

Use this api instead, graph user api can provide these properity, and I don't know what is sbx:

https://graph.microsoft.com/v1.0/users/{id | userPrincipalName}?$select=displayName,id,mail,jobTitle

enter image description here

==============================================

By the way, you can use this api to query user information of all the users in your tenant:

https://graph.microsoft.com/v1.0/users?$select=displayName,id,mail,jobTitle
Tiny Wang
  • 10,423
  • 1
  • 11
  • 29
  • Considering my API : do you think, this is the right way : https://graph.microsoft.com/v1.0/users/ID1234?$select=displayName,id,mail,jobTitle ? – AskMe Apr 27 '21 at 13:02
  • I wanted specific user information when I just pass the user ID ( in my case the user ID = ID1234) - How can I frame the API with this ID. Please note, this is example ID. The part you are hidden in your image, if you could make it visible with my example ID, will be a great help. – AskMe Apr 27 '21 at 13:13
  • Another thing, the ID showing in response is not matching with the Organization ID/Employ ID. The Emp ID is not searchable using this API. For Example, If someone pass the Emp ID programmatically from UI, then how can he/she get the results? What is the way to get the result if EmpID is passed from user interface? – AskMe Apr 27 '21 at 13:24
  • As we can see in the document, if we need to call this api, we need to set the user id or user principal name as the query parameter so that we can got information of the specific user. We can see the id and principal name in the query result in my answer above(framed in red) or in azure portal-> azure ad-> users-> select a user-> profile will show principal name and object id. – Tiny Wang Apr 27 '21 at 13:36
  • What I mean is that you can't use id like `ID1234` into the query parameter because graph api not support this kind of custom user id. If you'd like to use this kind of id in the query ui, you need to turn this id into the matching azure ad user object id and then execute the query. For example, user enter `ID1234` and click search, your program should obtain azure ad user object id which has a matching relationship with ID1234, and call the api with ad user object id. – Tiny Wang Apr 27 '21 at 13:40
  • You can see the object id format in this [sample response](https://learn.microsoft.com/en-us/graph/api/user-get?view=graph-rest-1.0&tabs=http#response-2). Or you can call the working fine api https://graph.microsoft.com/v1.0/me to see the object id of your own account. – Tiny Wang Apr 27 '21 at 13:42