diff --git a/Microsoft.Alm.Authentication/Src/Network.cs b/Microsoft.Alm.Authentication/Src/Network.cs index e439dfb6d..cd7fd2143 100644 --- a/Microsoft.Alm.Authentication/Src/Network.cs +++ b/Microsoft.Alm.Authentication/Src/Network.cs @@ -687,7 +687,7 @@ public async Task SetContent(HttpContent content) if (content is null) throw new ArgumentNullException(nameof(content)); - if (content.Headers.ContentType.MediaType != null + if (content.Headers.ContentType?.MediaType != null && (content.Headers.ContentType.MediaType.StartsWith("text/", StringComparison.OrdinalIgnoreCase) || content.Headers.ContentType.MediaType.EndsWith("/json", StringComparison.OrdinalIgnoreCase))) { @@ -755,7 +755,7 @@ public async Task SetContent(HttpContent content) lock (_syncpoint) { - _mediaType = content.Headers.ContentType.MediaType; + _mediaType = content.Headers.ContentType?.MediaType; _byteArray = asBytes; } }