diff --git a/src/PortableRest/RestClient.cs b/src/PortableRest/RestClient.cs index 5120686..207a23e 100644 --- a/src/PortableRest/RestClient.cs +++ b/src/PortableRest/RestClient.cs @@ -433,10 +433,11 @@ private static async Task GetResponseContent([NotNull] RestRequest restReq /// private static async Task GetRawResponseContent([NotNull] HttpResponseMessage response) { - //RWM: Explicitly check for NoContent... because the request was successful but there is nothing to do. - if (response.IsSuccessStatusCode && response.StatusCode != HttpStatusCode.NoContent) + //KW: If there's content I want to know what it is regardless of the wether the response has a success code + if (response.StatusCode != HttpStatusCode.NoContent) { - return await response.Content.ReadAsStringAsync().ConfigureAwait(false); + string stringContent = await response.Content.ReadAsStringAsync().ConfigureAwait(false); + return string.IsNullOrEmpty(stringContent) ? null : stringContent; } return null; } @@ -468,7 +469,10 @@ private static T DeserializeResponseContent([NotNull] RestRequest restRequest } catch (JsonSerializationException jEx) { - throw new PortableRestException("The JsonConverter failed. Please see InnerException for details.", jEx); + var prEx = new PortableRestException( + "The JsonConverter failed. Please see InnerException " + + $"for details. StatusCode {response.StatusCode} : ReasonPhrase {response.ReasonPhrase}", jEx); + throw prEx; } }