microsoftgraph / msgraph-sdk-dotnet

Microsoft Graph Client Library for .NET!
https://graph.microsoft.com
Other
695 stars 246 forks source link

CalendarView.Delta - Error Parsing OData Select and Expand failed: Value cannot be null. (Parameter 'initialState') #2678

Open adryone opened 6 days ago

adryone commented 6 days ago

Describe the bug

In the below code lines:

        string expand = "SingleValueExtendedProperties($filter=Id eq 'String {f0b37059-bb45-47a2-b119-44ecdf894aed} Name NumeroPratica')";

            var calendarView = await _graphClient.Me.Calendars[calendarId].CalendarView
            .Delta
            .GetAsDeltaGetResponseAsync(rq =>
            {
                rq.QueryParameters.StartDateTime = startDate.UtcStringFromTimeZone(TIME_ZONE);
                rq.QueryParameters.EndDateTime = endDate.UtcStringFromTimeZone(TIME_ZONE);
                rq.QueryParameters.Expand = new string[] { expand };
                rq.Headers.Add("Prefer", $"outlook.timezone=\"{TIME_ZONE}\"");
                rq.QueryParameters.Select = EVENT_FIELDS;
            });

the .Expand setting produces the error "Parsing OData Select and Expand failed: Value cannot be null. (Parameter 'initialState')"

Omitting the .Expand setting, there is no error.

The same .Expand setting is used in normal (no Delta) .CalendarView.GetAsync() request without error.

Expected behavior

Correct response (no exception).

How to reproduce

string expand = "SingleValueExtendedProperties($filter=Id eq 'String {f0b37059-bb45-47a2-b119-44ecdf894aed} Name NumeroPratica')";

            var calendarView = await _graphClient.Me.Calendars[calendarId].CalendarView
            .Delta
            .GetAsDeltaGetResponseAsync(rq =>
            {
                rq.QueryParameters.StartDateTime = startDate.UtcStringFromTimeZone(TIME_ZONE);
                rq.QueryParameters.EndDateTime = endDate.UtcStringFromTimeZone(TIME_ZONE);
                rq.QueryParameters.Expand = new string[] { expand };
                rq.Headers.Add("Prefer", $"outlook.timezone=\"{TIME_ZONE}\"");
                rq.QueryParameters.Select = EVENT_FIELDS;
            });

SDK Version

5.56.1

Latest version known to work for scenario above?

No response

Known Workarounds

No wotkaround

Debug output

image

Configuration

OS: windows 11 pro, x64

Other information

No response

andrueastman commented 5 days ago

Thanks for raising this @adryone

According to the API documentation at the link below, it looks like passing $select is not supported in this endpoint. Any chance you are able to get a successful response if you don't pass a select parameter?

https://learn.microsoft.com/en-us/graph/delta-query-events?tabs=http#use-query-parameters-in-a-delta-query-for-calendar-view

adryone commented 5 days ago

Hi andrueastman, thanks for your reply.

First of all a precisation: the error I receive is for the Expand parameter, not for the Select; I use the Select without problem (the fields returned are corresponding to my Select value).

I'm confused searching further documentation on this question.

At the link https://learn.microsoft.com/en-us/graph/api/event-delta?view=graph-rest-1.0&tabs=http#odata-query-parameters (dated on 10/27/2023) it seems you'll right. But at the link https://learn.microsoft.com/en-us/graph/delta-query-overview#optional-query-parameters (dated on 01/12/2024) it seems that the Expand parameter is NOT possible ONLY for USER and GROUP resource; the explanation of this limitation is here https://learn.microsoft.com/en-us/graph/delta-query-overview#limitations.

Thanks

adryone commented 5 days ago

Hi andrueastman,

starting from the issue at https://github.com/OData/odata.net/issues/1162, I've found the following pull request https://github.com/OData/odata.net/pull/2701.

I don't understand if this pr will be never solved; can you help me? is there a possible solution for my issue?

Thanks

andrueastman commented 3 days ago

At the link https://learn.microsoft.com/en-us/graph/api/event-delta?view=graph-rest-1.0&tabs=http#odata-query-parameters (dated on 10/27/2023) it seems you'll right.

As we are making the request to the calendar API, I believe we should rely on this documentation as the other document only addresses limitation in the groups/users api.

Any chance you can also post the question at the link below? As this repo is mainly intended for SDK related issues, we may not know if this is really supported and the API owners should be able to give clarity here.

https://aka.ms/askGraph

adryone commented 3 days ago

Hi andrueastman,

yes, I switch to the link you suggested.

Thanks