AskMe
AskMe

Reputation: 2577

How to Get user data using Microsoft graph API programmatically

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

Upvotes: 2

Views: 17979

Answers (1)

Tiny Wang
Tiny Wang

Reputation: 16146

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

Upvotes: 3

Related Questions