Skip to content

Unable to deserialize content from batch request, Graph API appears to be returning HTML which is not handled by SDK #2661

@FionaUoN

Description

@FionaUoN

Describe the bug

We are making batched requests into the Graph API using the SDK and after a certain number of requests, the Graph API seems to be returning an HTML response, causing the SDK to throw an exception.

Stack trace is as follows: :

Error occurred while getting batch response: Unable to deserialize content.. Exception: Microsoft.Graph.ClientException: Unable to deserialize content.---> System.Text.Json.JsonReaderException: '<' is an invalid start of a value. LineNumber: 0 | BytePositionInLine: 137.at System.Text.Json.ThrowHelper.ThrowJsonReaderException(Utf8JsonReader& json, ExceptionResource resource, Byte nextByte, ReadOnlySpan1 bytes)at System.Text.Json.Utf8JsonReader.ConsumeValue(Byte marker)at System.Text.Json.Utf8JsonReader.ReadSingleSegment()at System.Text.Json.Utf8JsonReader.Read()at System.Text.Json.JsonDocument.Parse(ReadOnlySpan1 utf8JsonSpan, JsonReaderOptions readerOptions, MetadataDb& database, StackRowStack& stack)at System.Text.Json.JsonDocument.Parse(ReadOnlyMemory`1 utf8Json, JsonReaderOptions readerOptions, Byte[] extraRentedArrayPoolBytes, PooledByteBufferWriter extraPooledByteBufferWriter)at System.Text.Json.JsonDocument.ParseAsyncCore(Stream utf8Json, JsonDocumentOptions options, CancellationToken cancellationToken)at Microsoft.Graph.BatchResponseContent.GetBatchResponseContentAsync()

Expected behavior

When the Graph API returns HTML in this way, the SDK should handle the exception and return the HTML to the caller in a structured way, to enable us to triage the issue.
We are currently working with Microsoft support teams, but without the ability to obtain what the actual HTML response from the underlying Graph API was, we cannot pinpoint the issue.

How to reproduce

We are making hundreds of batched requests, 20 at a time, from an Azure Function in C#.

The request being made was [https://graph.microsoft.com/v1.0/users/{useremailaddress}/events/?$filter=singleValueExtendedProperties/Any(ep](https://graph.microsoft.com/v1.0/users/%7buseremailaddress%7d/events/?$filter=singleValueExtendedProperties/Any(ep): ep/id eq 'String {redacted} Name {redacted}'and ep/value ne null)&$expand=singleValueExtendedProperties($filter = id eq 'String {redacted} Name {redacted}')&top=1000

SDK Version

5.56.0

Latest version known to work for scenario above?

No response

Known Workarounds

No response

Debug output

Click to expand log ```
</details>


### Configuration

_No response_

### Other information

_No response_

Metadata

Metadata

Assignees

Labels

type:bugA broken experience

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions