I have rest WCF service link and i create integration with it and made the call but i want to cast the response of the call to class object using c#
This response in JSON
{
"Response": {
"Code":-27,
"ErrorMessage":"Please call login first.",
"IsSuccess":false,"SuccessMessage":""
},
"AllBlocked":false,
"Consents":null,
"Total":0
}
public class GetConsentResponse
{
public int Total { get; set; }
public bool AllBlocked { get; set; }
public List<Consent> Consents { get; set; }
}
public class Consent
{
public string ConsentID { get; set; }
public bool Blocked { get; set; }
public string Type { get; set; }
}
HttpWebRequest httpRequest = (HttpWebRequest)WebRequest.Create(new Uri(serviceUri));
httpRequest.Accept = "application/json";
httpRequest.ContentType = "application/json";
httpRequest.Method = "GET";
using (HttpWebResponse httpResponse = (HttpWebResponse)httpRequest.GetResponse())
{
using (Stream stream = httpResponse.GetResponseStream())
{
GetConsentResponse response = new GetConsentResponse();
richTextBox1.Text = (new StreamReader(stream)).ReadToEnd();
}
}