Graph API Calendar Events from Room Security issue and Links

William E. Fisher 1 Reputation point
2023-02-14T19:35:06.12+00:00

Hello, I've been trying to build a simple SPFX web part to display events for a Room in Exchange. The call to get events from the calendar works with the admin but regular users that can see the rooms calendar get a 404 with the Graph API calendar call. I have the web part requiring Calendars.Read and Calendars.Read.Shared as listed below in the Solution and approved them when uploading the control so I assume there is another permission I need for them to get the events properly as trying the Graph API explorer I get the same error testing with a similar user, is there any details on what it may be?

Additionally I've been trying to set up web links to the events to view them in Outlook but the Web link in the result never loads (I have tried a mentioned fix of decoding an "=" in the URL mentioned in another post with no change) and the one suggested for new Outlook at the link give an error about repeated redirects. These are for the Work and school accounts option; what is the best way to make a working link. Thank youi.

https://learn.microsoft.com/en-us/graph/api/resources/event?view=graph-rest-1.0
User's image

Config value requesting permissions

	 "webApiPermissionRequests": [{
    "resource": "Microsoft Graph",
    "scope": "Calendars.Read"
},{
"resource": "Microsoft Graph",
    "scope": "Calendars.Read.Shared"
}]

The call as used in the code with the api call bolded


var limitcheck = this.props.limit;
        if(isNaN(+limitcheck))
        {
          limitcheck = "8";
        }
        this.props.context.msGraphClientFactory.getClient('3').then((client: MSGraphClientV3): void => {
      
        
            if (error) {
                console.error("Message is : " + error);
                return;
            }
            const calendarEvents: MicrosoftGraph.Event[] = eventsResponse.value;
            this.setState({
                events: calendarEvents
            });
        });
    });
 client.api('/users/' + this.props.Username +'/calendar/events?$top=' + limitcheck + '&$orderby=start/dateTime asc&$filter=start/dateTime ge \'' + (new Date()).toISOString() + '\'')
Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
11,872 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. CharanyaB-MSFT 1,891 Reputation points Microsoft Vendor
    2023-04-06T07:14:42.4333333+00:00

    Hi @William E. Fisher

    Thanks for reaching out!

    As per my understanding you are trying to fetch events from the rooms calendar. I can see that You have used Calendars.Read and Calendars.Read.Shared Delegated Permissions on the App. For other users to access the app please consent the app with Application Permissions with Calendars.Read Permission.

    API: GET /users/{id | userPrincipalName}/calendar/events 

    Please use this API to fetch the WebLink :   GET /users/{id | userPrincipalName}/calendar/events/{event-id}?$select=WebLink  User can use the retrieved weblink form the response to open the calendar event in outlook. 

    If still you are facing issue with accessing the Weblink, I would suggest you to report this by raising a support case with Microsoft, a dedicated Support Engineer will be able to assist you better. You can raise support ticket from [http://aad.portal.azure.com] or https://admin.microsoft.com/#/support/requests.

    Document reference: List events - Microsoft Graph v1.0 | Microsoft Learn 

    Hope this helps.

    If the reply is helpful, please click "Accept Answer" and kindly upvote it. If you have additional questions about this answer, please click "Comment".

    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.