Skip to content

Commit

Permalink
馃┕ fix create and return (accept 201 - created)
Browse files Browse the repository at this point in the history
  • Loading branch information
guimabdo committed Aug 25, 2023
1 parent 0ed5109 commit d7f5bee
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions OData.Client/HttpHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -244,21 +244,17 @@ static void AppendResponseInfo(StringBuilder sbLog, string responseText)

static void ThrowErrorIfNotOk(HttpResponseMessage responseMessage, string json)
{
if (responseMessage.StatusCode != HttpStatusCode.OK && responseMessage.StatusCode != HttpStatusCode.NoContent)
{
ThrowODataErrorIfItFits(json);
throw new HttpRequestException(responseMessage.StatusCode.ToString() + ": " + json);
}
if (responseMessage.IsSuccessStatusCode) { return; }
ThrowODataErrorIfItFits(json);
throw new HttpRequestException(responseMessage.StatusCode.ToString() + ": " + json);
}

static async Task ThrowErrorIfNotOk(HttpResponseMessage responseMessage)
{
if (responseMessage.StatusCode != HttpStatusCode.OK && responseMessage.StatusCode != HttpStatusCode.NoContent)
{
string json = await responseMessage.Content.ReadAsStringAsync();
ThrowODataErrorIfItFits(json);
throw new HttpRequestException(responseMessage.StatusCode.ToString() + ": " + json);
}
if (responseMessage.IsSuccessStatusCode) { return; }
string json = await responseMessage.Content.ReadAsStringAsync();
ThrowODataErrorIfItFits(json);
throw new HttpRequestException(responseMessage.StatusCode.ToString() + ": " + json);
}

static void ThrowODataErrorIfItFits(string json)
Expand Down

0 comments on commit d7f5bee

Please sign in to comment.