RJardines
RJardines

Reputation: 860

Microsoft-Graph SDK for .NET is not returning odata.nextLink after upgrading from v1.19 to latest

When I make a request to Graph API I get in the response the "@odata.nextLink", if I use .NET SDK v1.19 I still get the value in the AdditionalData and there is also a NextPageRequest property which has an instance to make a request to the next page. But after upgrading to the latest version 4.53, using the same query I get the response with the NextPageRequest instance but not the "@odata.nextLink" in the AdditionalData.

I took a look at the release notes and there is nothing mentioning this change.

I could take the info from the NextPageRequest but I would like to understand what is actually happening here.

Upvotes: 0

Views: 1037

Answers (2)

RJardines
RJardines

Reputation: 860

I found the reason for this issue, commit: https://github.com/microsoftgraph/msgraph-sdk-dotnet/commit/834549348081869cc4b97d9ead6dbbf12a516264?diff=split class GraphServiceUsersCollectionResponse

[JsonPropertyName("@odata.nextLink")]
public string NextLink { get; set; }

The addition of the above property removed the odata.nextLink from the AdditionalData dictionary. This is an old commit, I'm not sure why this has not been reported as a breaking change.

I'm going to open a ticket directly to the project.

enter image description here

Upvotes: 1

Tiny Wang
Tiny Wang

Reputation: 15906

I found the official document to recommend using PageIterator for Paging, so I checked the source code for different version and I think this can answer your question in some terms. I mean this is recommended by Microsoft and the way it used to get next page value should explain something....

And this is what I found in SDK version

dynamic page = _currentPage;
// There are more pages ready to be paged.
if (page.NextPageRequest != null)
{
    Nextlink = page.NextPageRequest.GetHttpRequestMessage().RequestUri.AbsoluteUri;
    return true;
}

enter image description here

And this is what I see in V1.19

if (_currentPage.AdditionalData.TryGetValue("@odata.nextLink", out var value))
{
     Nextlink = value as string;
     return true;
}

enter image description here

Upvotes: 1

Related Questions