HttpContent.ReadAsStringAsync
-
I am wondering if I am misunderstanding what HttpContent.ReadAsStringAsync is supposed to return.
I have an HttpPost that expects to receive a response with data in the Body (there is a reason behind this, but that is not what I want to discuss here). When I get the successful HttpResponseMessage, calling HttpResponseMessage.Content.ReadAsStringAsync() is returning a deserialized JSON object that contains all of the properties of HttpResponseMessage. The Uri being called initially is definitely setting the HttpResponseMessage.Content to a valid StringContent object.
Is my understanding incorrect, or is ReadAsStringAsync() not behaving as it is supposed to?
-
Your understanding is correct. It sounds like a problem with the server code. For example, you've got an endpoint declared as returning an
IActionResult
, and it returns anHttpResponseMessage
object.This SO thread might point you in the right direction.
-
Your understanding is correct. It sounds like a problem with the server code. For example, you've got an endpoint declared as returning an
IActionResult
, and it returns anHttpResponseMessage
object.This SO thread might point you in the right direction.
@Richard-Deeming said in HttpContent.ReadAsStringAsync:
Your understanding is correct. It sounds like a problem with the server code. For example, you've got an endpoint declared as returning an
IActionResult
, and it returns anHttpResponseMessage
object.This SO thread might point you in the right direction.
This turned out to be the problem. Thanks for your post.