8

I am trying to use Microsoft Graph Api to get and filter the address owner, and the address name of the calendars.

The permissions of my app are: enter image description here

enter image description here

enter image description here

I try to run this queries:

https://graph.microsoft.com/v1.0/me/calendars?$filter=owner/name eq 'Megan Bowen'

https://graph.microsoft.com/v1.0/me/calendars?$filter=owner/address eq 'noreply@Planner.Office365.com'

But the response is "ErrorInternalServerError"

enter image description here enter image description here

Why this queries have problems? How select a property of specific type?

https://graph.microsoft.com/v1.0/me/calendars?$select=owner/name

Thanks,

enter image description here

4
  • Is your goal to get the owner or to filter by owner? I'm not sure what the exact question is here. Jul 25, 2018 at 10:54
  • 2
    The goal is filter "eq" the calendars by the property of owner object, in this case "owner.name, owner.address" Jul 26, 2018 at 17:25
  • I have the same need, were you able to solve? Thanks. Jun 1, 2022 at 14:10
  • Hi @MassimoMagliani. no solution was found, the filter was implemented using Linq, not with a call to the Microsoft Graph API Jun 1, 2022 at 16:00

1 Answer 1

1
+25

Accessing calendars with Graph requires some configuration in permissions before the Graph call will work. What is required relates to the type of application and that drives the type of permissions – Delegate or Admin.
Below is information to help understand and help setting up the needed permissions.

Starting information:

For Graph to read from a shared mailbox (similar to Outlook delegate access), you need to set permissions in Azure and may also need to set sharing permissions. If you set Calendars.Read.Shared permissions then the user would need to share their calendar. If you set Calendars.Read for your application, then it can access all calendars in the org – there is no way to filter the scope.

Microsoft Graph permissions reference

Look under "Microsoft Graph permission names" and "Calendar permissions"

In Azure, set:

Calendars.Read.Shared permissions: Allows the app to read events in all calendars that the user can access, including delegate and shared calendars. (Delegated permissions)

or

Calendars.Read: Allows the app to read events of all calendars without a signed-in user. (Application Permissions)

It's the same for REST:

Outlook Calendar REST API reference

See "Using the Calendar REST API"

Delegate permissions:

For delegate permissions, three things are needed:

Calendar.Read.Shared or Calendar.ReadWrite.Shared in Azure. The user also needs to grant shared permission to the calendar. In the scope of requested permissions in your code, ask for the same permissions you granted in Azure. Here is how a user can share their calendar for an application using Delegate permissions:

Calendar sharing in Office 365

Share an Outlook calendar with other people

Admin permissions:

For Admin permissions (used by Background services or daemons Applications), Admin consent will need to be granted for Calendar.Read or Calendar.ReadWrite. This will allow the application to access all mailboxes in the organization. These permissions cannot be filtered to anything less than all mailboxes.

Get access without a user

Additional:

How to get a list of Shared mailboxes and users with permissions to those mailboxes in Exchange Online?

Be sure to also read the following, which covers how the credentials flow:

Azure Active Directory v2.0 and the OAuth 2.0 client credentials flow

Information on permission scopes:

Scopes, permissions, and consent in the Azure Active Directory v2.0 endpoint Permission scopes | Graph API concepts

If all permissions are set correctly
Then you should be able to do a rest call with this query:

https://graph.microsoft.com/v1.0/users/upn@domain.tld/calendars

Here upn@domain.tld needs to be the UserPrincipalName of the user you wish to look up.

As a side note, any REST query you make with spaces in it will fail. If you need to call something with spaces, you need the querystring to escape the space with %20

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.