Example #1
0
        public Kolonne2 GetOne(int id)
        {
            Kolonne2 returnOne = new Kolonne2();

            using (HttpClient client = new HttpClient())
            {
                Task <string> resTask = client.GetStringAsync(URI + "/" + id);
                string        jsonStr = resTask.Result;

                returnOne = JsonConvert.DeserializeObject <Kolonne2>(jsonStr);
            }

            return(returnOne);
        }
Example #2
0
        public void Put(int id, Kolonne2 obj)
        {
            using (HttpClient client = new HttpClient())
            {
                string        jsonStr = JsonConvert.SerializeObject(obj);
                StringContent content = new StringContent(jsonStr, Encoding.UTF8, "application/json");

                Task <HttpResponseMessage> putAsync = client.PutAsync(URI + "/" + id, content);

                HttpResponseMessage resp = putAsync.Result;
                if (resp.IsSuccessStatusCode)
                {
                    string jsonResStr = resp.Content.ReadAsStringAsync().Result;
                }
            }
        }