This is my webapi post request
[HttpPost]
[Route("Create/{id}")]
public async Task<IActionResult> CreateContact(Guid id, string email, string fullName)
{
// code removed for brevity
}
How do I post contact
object over to the webapi? This is what I have in the client.
using (var client = new HttpClient())
{
client.BaseAddress = new Uri("https://localhost:123");
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
var contact = new Contact() { Id = 12345, Email = "test@gmail.com", FullName = "John" };
HttpResponseMessage response = await client.PostAsJsonAsync($"/api/Contact/Create/{contact.Id}", contact);
if (response.IsSuccessStatusCode)
{
}
else
{
}
}