OneDrive / onedrive-sdk-csharp

OneDrive SDK for C#! https://dev.onedrive.com
Other
294 stars 143 forks source link

Selecting for @content.downloadUrl is lost in delta pagination #154

Closed jtippet closed 8 years ago

jtippet commented 8 years ago

If you ask to select the @content.downloadUrl, it works fine on the first page. But it's lost when you go to the 2nd page.

Repro:

  1. Create a folder (this code uses your appfolder), and put a few files in it.
  2. Run this code:
IOneDriveClient _onedrive = . . . ;

var options = new List<Option>
{
    new QueryOption("select", "name,@content.downloadUrl,file"),
    new QueryOption("top", "4"),
};

var page = await _onedrive.Drive.Special.AppRoot.Delta(null).Request(options).GetAsync();

while (true)
{
    foreach (var item in page.Where(c => c.File != null))
        System.Diagnostics.Debug.Assert(item.AdditionalData?["@content.downloadUrl"] != null);

    if (page.NextPageRequest == null)
        break;

    page = await page.NextPageRequest.GetAsync();
}

It works fine for the first page -- each file has a @content.downloadUrl. But when you get to the second page, the whole AdditionalData is null, and the assertion fires.

Looking through the private members of the ItemDeltaRequest, its QueryOptions has a $select=name,file. It managed to keep the other things I had in the select -- somehow it just lost the one.

jtippet commented 8 years ago

In fact, you can put almost any random thing in the select, and it'll round-trip through to each page. E.g.,

new QueryOption("select", "name,@content.downloadUrl,file,abracadabra"),

will have abracadabra in each page's QueryOptions. It seems like only tokens that begin with @ get dropped.

jtippet commented 8 years ago

One workaround is to add the @content.downloadUrl back again each time you move to the next page.

page = await page.NextPageRequest.Select("@content.downloadUrl").GetAsync();
cdmayer commented 8 years ago

Please re-open this issue against the API docs as this is not an SDK issue. https://github.com/OneDrive/onedrive-api-docs