Unable to get company user information on microsoft API

I have a problem with the Microsoft API ... I currently have a web application with open integration with Microsoft / Azure using a common v2 endpoint.

We are trying to get a signed username and job information. The official docs say we need to make a request to the MS Graph API.

We test it on Microft Graph Explorer but it doesn't seem to work.

We selected "User.Read" as the permission in our application and then tried these endpoints:

https://graph.microsoft.com/v1.0/me/
https://graph.microsoft.com/v1.0/me?$select=companyName,jobTitle
https://graph.microsoft.com/v1.0/users/?$select=companyName,jobTitle

      

The MS offical doc ( https://developer.microsoft.com/en-us/graph/docs/concepts/permissions_reference ) clearly states in the User / Notes sections that "On reads, only a limited number of properties are returned by default. To read properties that are not in the default set, use $select"

Is this document out of date? I tried to get MS support for developers, but they replied that I should ask this on Stack Overflow ... So maybe there is no official developer support? Is it really possible to get company name and job title from MS account?

Thanks in advance!

change. Refresh question with MS Graph explorer screenshots enter image description here enter image description here

edit.2. Update the screenshot with the correct encoding.

Also, this MS account is not an Azure account as our web app accepts both of them on a common v2 endpoint.

Update

My goal was to get the section Work Info

from the MSA account. enter image description here

+3


source to share


1 answer


The documentation is correct, by default we only return a subset of user properties :

  • id
  • userPrincipalName
  • displayName
  • givenName
  • surname
  • jobTitle
  • post office
  • mobilePhone
  • businessPhones
  • officeLocation
  • preferredLanguage

If you need a different set of properties, you can query them using a query parameter $select

. The queries you provided in your question should work fine. For example, when I execute https://graph.microsoft.com/v1.0/me?$select=companyName

in Graph Explorer (after logging in with my credentials), I get this:



{
    "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users(companyName)/$entity",
    "companyName": "MICROSOFT"
}

      

MSA update

When using Microsoft Graph for Microsoft Account (MSA), there are several differences in property properties. Since an MSA is by definition a personal / individual account, organizational properties such as Job Title and Office Location are simply not applicable.

+2


source







All Articles