question

JohnMcGuigan-2435 avatar image
0 Votes"
JohnMcGuigan-2435 asked CarlZhao-MSFT edited

Graph API permissions issue

Hi,

I am trying to get WorkingHours from Mailbox settings for my users. I have set the API permissions in Azure, and in Graph Explorer and if I run the below query with my email address it works fine. But as soon as I change the email address to one of my users it errors as per the screenshot. Both Azure and Explorer say I've consented so I'm a bit bemused.

https://graph.microsoft.com/v1.0/users/blah@blah.com.au/mailboxsettings/workinghours

To confuse things even more, if I use Connect-MGGraph with a certificate I can pull these details out for each person, but as I am doing this as part of a login script to update the Outlook signature the Connect-MGGraph option is not feasible.

183112-graphexplorer-question.png


microsoft-graph-applicationsmicrosoft-graph-permissionsazure-ad-app-consent
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

CarlZhao-MSFT avatar image
0 Votes"
CarlZhao-MSFT answered CarlZhao-MSFT edited

Hi @JohnMcGuigan-2435

Graph Explorer does not support calling the /users/{user id} endpoint, you can only use it to call the /me endpoint: me/mailboxsettings/workinghours.

The /users/{user id} endpoint is usually adapted to the application context, so you should grant your application the MailboxSettings.Read application permission in Azure AD, then use the client credentials flow to get the token and call the /users/{id|userPrincipalName}/mailboxsettings/workinghours api endpoint in postman.

183107-2022-03-15-151929.png

183128-image.png


If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.



image.png (59.0 KiB)
· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi

thanks for the response, the Azure consents have been granted. I can read the working hours etc from the Powershell Connect-MGGraph module, but I'll check my script that uses the API url and see if it is still erroroing.

1 Vote 1 ·

Hi

Looks like it was the Graph Explorer error that was throwing me off track, have tried plugging the code into my script and it seems to be functioning. Now to see whether it still works as part of a logon script pushed via GPO.

1 Vote 1 ·
CarlZhao-MSFT avatar image CarlZhao-MSFT JohnMcGuigan-2435 ·

Hi @JohnMcGuigan-2435

Would you please provide us with an update on the status of your issue?


Please do not forget to "Accept Answer" and “up-vote” wherever the information provided helps you, this can be beneficial to other community members.


0 Votes 0 ·
michev avatar image
0 Votes"
michev answered

I seem to be able to reproduce this, let me see if I can bring some help.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.