Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Prefer" request header in PageIterator #2731

Open
WolfgangHG opened this issue Nov 1, 2024 · 0 comments
Open

"Prefer" request header in PageIterator #2731

WolfgangHG opened this issue Nov 1, 2024 · 0 comments
Labels
status:waiting-for-triage An issue that is yet to be reviewed or assigned

Comments

@WolfgangHG
Copy link

You can create a request that fetches a calendar item content as plain text like this:

EventCollectionResponse eventCollResponse = await graphClient.Me.Calendar.Events.GetAsync(
  c =>
  {
    c.Headers.Add("Prefer", "outlook.body-content-type=\"text\"");
  });

You could put this response object in an iterator:

PageIterator<Event, EventCollectionResponse> iterator = PageIterator<Event, EventCollectionResponse>.CreatePageIterator(graphClient, eventCollResponse,
  (eventAktuell) =>
  {
    //Do something....
    return true;
  });

But there, the "Prefer" header is only applied to the first page, the rest of the calendar items returns the html body.

Solution/Workaround: set the header in the iterator instead:

PageIterator<Event, EventCollectionResponse> iterator = PageIterator<Event, EventCollectionResponse>.CreatePageIterator(graphClient, eventCollResponse,
  (eventAktuell) =>
  {
    //Do something....
    return true;
  },
  c =>
  {
    c.Headers.Add("Prefer", "outlook.body-content-type=\"text\"");
  }));

One might expect that the header for the initial request is applied to all pages of the iterator.

What do you think? Is the current behavior expected, or is this something that could be improved? It could either copy headers from the "TCollectionPage" to each page request. Or it could also raise an exception if the "TCollectionPage" contains headers instead of providing them to the iterator itself, as it probably has unexpected results if using it this way.

@WolfgangHG WolfgangHG added the status:waiting-for-triage An issue that is yet to be reviewed or assigned label Nov 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status:waiting-for-triage An issue that is yet to be reviewed or assigned
Projects
None yet
Development

No branches or pull requests

1 participant