0

I am capturing a HttpResponseMessage using C#. I see the Headers and Content easily using C# and Telerik Fiddler. How do I get to the Json Message ={"error_message":"Unable to find Category 130"}? This is the response that is being returned from a third party vendor

HttpResponse:

HTTP/1.1 200 OK
Access-Control-Allow-Origin: *
Cache-control: no-cache="set-cookie"
Content-Type: application/xxxxxxxx;version=1.0
Date: Thu, 23 Jan 2020 20:14:18 GMT
Server: Apache/2.4.7 (Ubuntu)
Set-Cookie: AWSELB=B951170B0258C274F4328378523700A29FEEC6BAABF6103540B7038DA196F54B6874B912614AC1E0CD2E8767C34FC2E6F1E24E6532E90C88E5E4413E3E7A09EFA6074CFAC1;PATH=/;MAX-AGE=300
Content-Length: 47
Connection: keep-alive

{"error_message":"Unable to find Category 130"}
Michael Bruesch
  • 632
  • 7
  • 23
user1633146
  • 359
  • 3
  • 12
  • Unfortunately, this is "normal". 200 means OK.https://httpstatuses.com/200 but in many cases, web API's are developed incorrectly and the response has error without a different statuscode . The problem is most likely on the side of the third party. In Fiddler, you can copy the RAW Request en then try it in VSCode REST Client to demonstrate the problem (preferably with Fiddler closed).https://marketplace.visualstudio.com/items?itemName=humao.rest-client – Daan Jan 23 '20 at 20:51
  • 1
    Does this answer your question? [How can I parse JSON with C#?](https://stackoverflow.com/questions/6620165/how-can-i-parse-json-with-c) – miken32 Jan 23 '20 at 23:00

1 Answers1

0

So how I went about solving this issue with Http Response being returned with statuscode of 200 but and error message in the content, is to include looking for a error in the Response.Content.ReadAsStringAsync().Result

user1633146
  • 359
  • 3
  • 12