Calendarview call in c# not working with msgraph-sdk-dotnet / visual studio

Dirk Oppenländer 0 Reputation points
2023-03-03T07:13:39.12+00:00

Hi,

since calling the eventlist does not return reoccuring events from event series i am trying to get the calendarview with the new syntax requestConfiguration.QueryParameters.Filter.

in lack of Documentation i am not able to get it to work - instead i geet an ODataError exception.

My Syntax (which worked fine for events) for the Calendarview ist as follows:

Please give me a hint what i am missing....

 calendarEvents = await graphServiceClient
        .Users[mailid]
        .CalendarView
        .GetAsync(requestConfiguration =>
        {
            requestConfiguration.QueryParameters.Filter = "start/dateTime ge '2023-03-02T00:00:00.0000000Z' and end/dateTime le '2023-03-03T23:59:00.0000000Z'";
        });
Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,521 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Shivam Dhiman 5,946 Reputation points
    2023-03-03T15:15:54.2533333+00:00

    Hi @Dirk Oppenländer

    As per the documentation you can use this C# Graph SDK.

    var graphClient = new GraphServiceClient(requestAdapter);
    
    var result = await graphClient.Users["{user-id}"].CalendarView.GetAsync((requestConfiguration) =>
    {
        requestConfiguration.QueryParameters.StartDateTime = "2023-02-01T19:00:00-08:00";
        requestConfiguration.QueryParameters.EndDateTime = "2023-03-02T19:00:00-08:00";
    });
    
    

    Instead of using ge/le use '=' and pass date range as start and end. This will give all the events in start and end range and no need to use filter while passing start and end date.

    Hope this helps.

    If the answer is helpful, please click Accept Answer and kindly upvote. If you have any further questions about this answer, please click Comment.

    0 comments No comments