How to receive HTML response from WEB API in C#

Viewed 28

How to receive and print below error in C#.(See below screeshot)

enter image description here

This error is coming while posting the data to customer WEB API.

Code block used for Posting data to customer API.

var response = client.PostAsync(URL, content).Result;
Console.WriteLine("Status Code:" + (int)response.StatusCode); //output = 404
Console.WriteLine("Reason:" + response.ReasonPhrase); //output = Not Found

Please suggest?

1 Answers

try this var body = await response.Content.ReadAsStringAsync();

Related