Reputation: 931
I am doing a post request and reading the response as given
var response = client.PostAsync(uriBuilder.Uri.ToString(), Content).Result;
var value = response.Content.ReadAsStreamAsync().Result;
if the result is a proper json string, it populates that in 'value' variable otherwise it returns empty.
but if run the same in postman or fiddler i get this as response
Is there a way to get this response too?
Upvotes: 1
Views: 850
Reputation: 6966
ReadAsStreamAsync()
returns a Task<System.IO.Stream>
and not a Task<string>
. The json string that you see is probably the debugger showing you the content of the stream.
Consider using ReadAsStringAsync()
to get the HTML content :
var response = await client.PostAsync(uriBuilder.Uri.ToString(), Content);
var result = await response.Content.ReadAsStringAsync();
Upvotes: 1