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

Add access to Headers in BatchRequestContentCollection #862

Open
Dethras opened this issue Aug 5, 2024 · 4 comments
Open

Add access to Headers in BatchRequestContentCollection #862

Dethras opened this issue Aug 5, 2024 · 4 comments
Labels

Comments

@Dethras
Copy link

Dethras commented Aug 5, 2024

Is your feature request related to a problem? Please describe the problem.

I have a specific case where I need to pass something through a Header to be accessed in a DelegatingHandler, with the addition of BatchRequestContentCollection, BatchRequestContent has become obsolete, and there is no way to access the Headers via BatchRequestContentCollection or via graphClient.Batch.PostAsync(BatchRequestContentCollection)

Describe the solution you'd like.

BatchRequestContentCollection or graphClient.Batch.PostAsync(BatchRequestContentCollection) should accept RequestHeaders/RequestInformation, and they should be added with every batch call made with the graphClient.Batch.PostAsync(BatchRequestContentCollection).

Additional context?

No response

@Dethras Dethras added status:waiting-for-triage An issue that is yet to be reviewed or assigned type:feature New experience request labels Aug 5, 2024
@andrueastman
Copy link
Member

Thanks for raising this @Dethras

To clarify,

  • is this header for each individual request? Or for the entire batch request message?
  • is this scenario possible with BatchRequestContent but not with BatchRequestContentCollection?

@andrueastman andrueastman added status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close and removed status:waiting-for-triage An issue that is yet to be reviewed or assigned labels Aug 6, 2024
@Dethras
Copy link
Author

Dethras commented Aug 6, 2024

Hi @andrueastman

  1. This is for the entire batch request (For the https://graph.microsoft.com/v1.0/$batch call) [Note: For each individual request it is already supported through BatchRequestStep]
  2. It is possible through BatchRequestContent since I can use graphClient.Batch.ToPostRequestInformationAsync and then access the RequestHeaders through the RequestInformation

@microsoft-github-policy-service microsoft-github-policy-service bot added Needs: Attention 👋 and removed status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close labels Aug 6, 2024
@andrueastman
Copy link
Member

Thanks for the extra information here @Dethras

In my head, BatchRequestContentCollection still ends up splitting the requests into BatchRequestContent instances as the API only accepts 20 items at a time. So, this may still be possible.

Any chance you can also share a code example of how you send the request once you get the RequestInformation object?

@andrueastman andrueastman added status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close and removed Needs: Attention 👋 labels Aug 7, 2024
@Dethras
Copy link
Author

Dethras commented Aug 9, 2024

@andrueastman Apologies for the late reply.

Here is how I am currently doing it using the BatchRequestContent and it's ToPostRequestInformationAsync

var batchToProcess = new BatchRequestContent(graphClient, <Insert max 20 BatchRequest Steps Here>)
var requestInfo = await graphClient.Batch.ToPostRequestInformationAsync(batchToProcess);

requestInfo.Headers.Add(<Header Name>,<Header Value>);

var locationResponseHandler = new NativeResponseHandler();

requestInfo.SetResponseHandler(locationResponseHandler);

await graphClient.RequestAdapter.SendNoContentAsync(requestInfo, cancellationToken: cancellationToken);

var batchResponse = new BatchResponseContent(locationResponseHandler.Value as HttpResponseMessage);
var responses = await batchResponse.GetResponsesStatusCodesAsync();

@microsoft-github-policy-service microsoft-github-policy-service bot added Needs: Attention 👋 and removed status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close labels Aug 9, 2024
@baywet baywet added status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close and removed status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close labels Feb 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants