I have a piece of code to read HttpResponseContent
using windows.web.http
:
using System.IO;
using Windows.Web.Http;
using Newtonsoft.Json;
var responseContent = JsonConvert.DeserializeObject<HttpResponseContent>(response.Content.ToString());
if (response.StatusCode == HttpStatusCode.Ok)
{
//convert only from this line
using (var input =
await response.Content.ReadAsInputStreamAsync()
.AsTask()
.ConfigureAwait(false))
using (var stream = input.AsStreamForRead())
using (StreamReader sr = new StreamReader(stream))
using (JsonReader reader = new JsonTextReader(sr)) //to this line
{
return DeserializeData(reader);
}
Question 1: How can I achieve this using system.net.http
namespace?
Note: I wrote those codes in uwp
using windows.web.http
, what I want is to convert that code using different package/namespace, which is system.net.http
which I am using in Azure Functions.
Reference Link: https://learn.microsoft.com/en-us/dotnet/api/system.net.http?view=netframework-4.7.2 https://learn.microsoft.com/en-us/uwp/api/windows.web.http
Thanks