diff --git a/src/Microsoft.Graph.Core/Requests/BatchRequestBuilder.cs b/src/Microsoft.Graph.Core/Requests/BatchRequestBuilder.cs index 74e2a6581..de4b8d7c1 100644 --- a/src/Microsoft.Graph.Core/Requests/BatchRequestBuilder.cs +++ b/src/Microsoft.Graph.Core/Requests/BatchRequestBuilder.cs @@ -123,7 +123,11 @@ private static async Task ThrowIfFailedResponseAsync(HttpResponseMessage httpRes var responseStringContent = string.Empty; if (httpResponseMessage.Content != null) { +#if NET5_0_OR_GREATER + responseStringContent = await httpResponseMessage.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); +#else responseStringContent = await httpResponseMessage.Content.ReadAsStringAsync().ConfigureAwait(false); +#endif } throw new ServiceException(ErrorConstants.Messages.BatchRequestError, httpResponseMessage.Headers, (int)httpResponseMessage.StatusCode, responseStringContent);