2

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

3
  • Could you specifiy what do you mean by sbx, cn and uid? Commented Apr 27, 2021 at 10:39
  • Its the details people usually get while trying to find details from LDAP. cn = common name, uid is user id. stackoverflow.com/questions/18756688/… Commented Apr 27, 2021 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 : ) Commented Apr 27, 2021 at 14:16

1 Answer 1

3

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
Sign up to request clarification or add additional context in comments.

6 Comments

Considering my API : do you think, this is the right way : graph.microsoft.com/v1.0/users/… ?
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.
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?
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.
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.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.