Graph API permissions issue

John McGuigan 31 Reputation points
2022-03-15T04:15:34.553+00:00

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[@](/users/na/?userId=90ae04c7-7ffe-0003-0000-000000000000).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 Security Microsoft Entra Microsoft Entra ID
Microsoft Security Microsoft Graph
0 comments No comments
{count} votes

Accepted answer
  1. CarlZhao-MSFT 46,366 Reputation points
    2022-03-15T07:13:55.997+00:00

    Hi @John McGuigan

    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.


1 additional answer

Sort by: Most helpful
  1. Vasil Michev 119.5K Reputation points MVP Volunteer Moderator
    2022-03-15T07:24:19.82+00:00

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

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.