private static void PostWidget(Widget widgetToPost) { using (var client = new HttpClient()) { client.BaseAddress = new Uri("https://httplistener665965b5ace64eee82c005b953910aeb.azurewebsites.net/"); client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); var response = client.PostAsJsonAsync("testycall", widgetToPost).Result; if (response.IsSuccessStatusCode) { Console.WriteLine(response.Content); } } }
static void Main(string[] args) { //var task = MakeRequestBinRequest("http://requestb.in/1069rk01"); //var task = SagApiValuesRequest("http://sagrestapi.azurewebsites.net/api/values/"); //var task = MakeRequestBinPost("http://httplistener665965b5ace64eee82c005b953910aeb.azurewebsites.net/testycall"); //task.Wait(); //var response = task.Result; //var body = response.Content.ReadAsStringAsync().Result; //Console.WriteLine(body); var widget = new Widget { Name = "AlokWidget", DateCreated = DateTime.Now, WidgetId = 100 }; PostWidget(widget); Console.ReadLine(); }