I want to post an object using an API call. I’m getting the data using the following code in my codebehind
HttpClient client = new HttpClient();
client.BaseAddress = new Uri(ConfigurationManager.AppSettings["JUri"]);
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
HttpResponseMessage response = client.GetAsync("api/receipt/" + jID).Result;
if (response.IsSuccessStatusCode)
{}
I would like to know there is any code equivalent to POST for this.
POST using Form:
POST using JSON, assume you have Dto class: