Skip to content

fix: resolved error handling of larger batch request message #916

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

Merged
merged 10 commits into from
Sep 10, 2024
3 changes: 2 additions & 1 deletion src/Microsoft.Graph.Core/Requests/BatchRequestBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ private static async Task ThrowIfFailedResponseAsync(HttpResponseMessage httpRes
{
if (httpResponseMessage.IsSuccessStatusCode) return;

if (CoreConstants.MimeTypeNames.Application.Json.Equals(httpResponseMessage.Content?.Headers?.ContentType?.MediaType, StringComparison.OrdinalIgnoreCase))
var contentTypeString = httpResponseMessage.Content?.Headers?.ContentType?.MediaType is { } contentTypeMediaType && !string.IsNullOrEmpty(contentTypeMediaType) ? contentTypeMediaType : string.Empty;
if (httpResponseMessage.Content != null && contentTypeString.StartsWith(CoreConstants.MimeTypeNames.Application.Json, StringComparison.OrdinalIgnoreCase))
{
using var responseContent = await httpResponseMessage.Content.ReadAsStreamAsync().ConfigureAwait(false);
using var document = await JsonDocument.ParseAsync(responseContent).ConfigureAwait(false);
Expand Down
Loading