What should HttpContentExtensions.ReadAsAsync
and HttpContent.ReadAsStringAsync
be used for?
They would seem to do similiar t
ReadAsStringAsync: This is a basic "get me the content as a string" method. It will work on anything you throw at it because it's just strings.
ReadAsAsync
var result = JsonConvert.SerializeObject("hello world");
Console.WriteLine(result);
Output is:
"hello world"
Note how it is surrounded by double quotes. If you try to deserialise any arbitrary JSON directly into a string that isn't in the format "....."
it will throw the exception you see because it is expecting the JSON to start with a "
.