/// <summary> /// Runs an HttpClient issuing a POST request against the controller. /// </summary> static async void RunClient() { HttpClient client = new HttpClient(); Contact contact = new Contact { Name = "Henrik", Age = 100 }; // Post contact Uri address = new Uri(_baseAddress, "/api/contact"); HttpResponseMessage response = await client.PostAsJsonAsync(address.ToString(), contact); // Check that response was successful or throw exception response.EnsureSuccessStatusCode(); // Read result as Contact Contact result = await response.Content.ReadAsAsync<Contact>(); Console.WriteLine("Result: Name: {0} Age: {1}", result.Name, result.Age); }
public Contact Post(Contact contact) { return contact; }