In my ASP.Net REST controller I do the following:
return BadRequest("A problem happened!"); When calling this over HTTP I get the message as follows:
HttpResponseMessage response = await _httpClient.GetAsync(url); if (!response.IsSuccessStatusCode) { var errorMessage = await response.Content.ReadAsStringAsync(); But the value of the errorMessage is:
"\"A problem happened!\"" When I run through PostMan it doesn't include the quote marks even in the raw output view so I'm not sure if they are being added on for some reason, but I would rather avoid having to manually strip them.
I based my work on this other question where nobody seemed to have this issue: BadRequest custom error message not returned to client?