I use the HttpClient class and with GET on the API instead of the JSON format, I get a string of this type. Although if you go through the browser it returns normally.

 {\"error\":false,\"message\":\"\\u0417\\u0430\\u043f\\u0440\\u043e\\u0441 \\u0432\\u044b\\u043f\\u043e\\u043b\\u043d\\u0435\\u043d \\u0443\\u0441\\u043f\\u0435\\u0448\\u043d\\u043e\",\"response\":[{\"id_room\":5,\"id_doctor\":2,\"full_name\":\"\\u0413\\u043e\\u043b\\u043e\\u0432\\u0438\\u043d \\u041f\\u0435\\u0442\\u0440 \\u041c\\u0438\\u0445\\u0430\\u0439\\u043b\\u043e\\u0432\\u0438\\u0447\"},{\"id_room\":6,\"id_doctor\":3,\"full_name\":\"\\u0417\\u0430\\u0445\\u0430\\u0440\\u043e\\u0432 \\u0410\\u043b\\u0435\\u043a\\u0441\\u0435\\u0439 \\u0421\\u0435\\u0440\\u0433\\u0435\\u0435\\u0432\\u0438\\u0447\"},{\"id_room\":4,\"id_doctor\":4,\"full_name\":\"\\u0421\\u0443\\u0432\\u043e\\u0440\\u043e\\u0432 \\u0414\\u043c\\u0438\\u0442\\u0440\\u0438\\u0439 \\u0421\\u0435\\u0440\\u0433\\u0435\\u0435\\u0432\\u0438\\u0447\"}]}" 

 public async void Getasdas() { HttpClient client = new HttpClient(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); UserList user = new UserList(); var response = await client.GetAsync("http://192.168.0.110/mh_api/v1/rooms/1"); var responseBody = await response.Content.ReadAsStringAsync(); } 

    2 answers 2

    Recode to JSON. This is a common practice. It is necessary to execute JSON encode (unfortunately in C # I don’t know how to implement it, because I didn’t write on it, but this problem appears not only in C #).

    FIXED:

     JObject json = JObject.Parse(str); 
    • Thank you, solved the issue. - ID

    I use HttpWebRequest .

      private string getContent(string url) { HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); request.Method = "GET"; request.Accept = "application/json"; request.UserAgent = "Mozilla/5.0 ...."; HttpWebResponse response = (HttpWebResponse)request.GetResponse(); StreamReader reader = new StreamReader(response.GetResponseStream()); StringBuilder output = new StringBuilder(); output.Append(reader.ReadToEnd()); response.Close(); return output.ToString(); } 
    • Thanks, but I need using HttpClient . There it is then more convenient to send POST requests. - Identin