Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR HTML

how to deserialize if response is html

        HttpClient client = new HttpClient();
        client.BaseAddress = new Uri(url);
        client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
        HttpResponseMessage response = client.GetAsync(url).Result;

        if (response.IsSuccessStatusCode)
        {
            var result  = response.Content.ReadAsStringAsync().Result;
            var s = Newtonsoft.Json.JsonConvert.DeserializeObject(result);
            return "Success";
        }
        else
        {
            return "Fail";
        }
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #deserialize #response #html
ADD COMMENT
Topic
Name
6+9 =