public RengøringsKolonne GetOne(int id) { RengøringsKolonne returnOne = new RengøringsKolonne(); using (HttpClient client = new HttpClient()) { Task <string> resTask = client.GetStringAsync(URI + "/" + id); string jsonStr = resTask.Result; returnOne = JsonConvert.DeserializeObject <RengøringsKolonne>(jsonStr); } return(returnOne); }
public void Post(RengøringsKolonne obj) { using (HttpClient client = new HttpClient()) { string jsonStr = JsonConvert.SerializeObject(obj); StringContent content = new StringContent(jsonStr, Encoding.ASCII, "application/json"); Task <HttpResponseMessage> postAsync = client.PostAsync(URI, content); HttpResponseMessage resp = postAsync.Result; if (resp.IsSuccessStatusCode) { string jsonResStr = resp.Content.ReadAsStringAsync().Result; } } }