microsoftgraph / microsoftgraph/msgraph-sdk-dotnet-core
Unable to get Streams using batched requests, Length always zero
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 164
- Forks
- 65
- Avg merge
- 38m
- Merged PRs (30d)
- 1
Description
Describe the bug
When using BatchRequestContentCollection (or BatchRequestContent) to request a stream content it only returns an empty stream (Length = 0). This happens regardless of whether there is a single or multiple requests in the collection.
var batchRequestContentCollection = new BatchRequestContentCollection(_graphClient);
var driveItemRequest = _graphClient.Drives[driveId].Items[driveItemId].Content.ToGetRequestInformation();
var requestId = await batchRequestContentCollection.AddBatchRequestStepAsync(driveItemRequest);
var batchResponse = await _graphClient.Batch.PostAsync(batchRequestContentCollection);
var stream = await batchResponse.GetResponseStreamByIdAsync(requestId);
I also tried to just use GetResponseByIdAsync, Header information says
Content-Type: application/octet-stream
Content-Length: 0
This does not occur when doing a single request without batching:
var stream = await _graphClient.Drives[driveId].Items[driveItemId].Content.GetAsync();
The stream gets returned correctly then.
Expected behavior
Batched requests should return stream content correctly.
How to reproduce
var batchRequestContentCollection = new BatchRequestContentCollection(_graphClient);
var driveItemRequest = _graphClient.Drives[driveId].Items[driveItemId].Content.ToGetRequestInformation();
var requestId = await batchRequestContentCollection.AddBatchRequestStepAsync(driveItemRequest);
var batchResponse = await _graphClient.Batch.PostAsync(batchRequestContentCollection);
var stream = await batchResponse.GetResponseStreamByIdAsync(requestId);
SDK Version
3.2.1
Latest version known to work for scenario above?
don't know
Configuration
- OS: Windows 11
- x64
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with BatchRequestContentCollection.AddBatchRequestStepAsync, Batch.PostAsync, and GetResponseStreamByIdAsync using the provided drive-item content request. Compare the batched response with the direct Content.GetAsync response and inspect the returned headers and stream. Done means batched stream responses contain the requested content instead of Content-Length: 0.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100