コード例 #1
0
        public async Task <bool> addCustomer(Customer item)
        {
            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri("http://httpbin.org/");
                client.DefaultRequestHeaders.Accept.Clear();
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

                string customerJson          = _jsonParser.CustomerToJsonString(item);
                HttpResponseMessage response = await client.PostAsync("post", new StringContent(customerJson));

                if (response.IsSuccessStatusCode)
                {
                    return(true);
                }

                return(false);
            }
        }