How to insert Windows Form Data Into Database Using Web API?
Web api insert function
3 Answers
Know the answer? Post it. Somebody with the same question will find it here.
How to insert Windows Form Data Into Database Using Web API?
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Kirtesh ShahRank #250 · 10K reputationPosted Oct 28, 2021, 12:46 AM EDT
Sachin SinghRank #66 · 26.2K reputationPosted Oct 28, 2021, 12:47 AM EDT
use HttpClient as shown below
public void Save()
{
static HttpClient client = new HttpClient();
client.BaseAddress = new Uri("http://localhost:4354/api/");
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(
new MediaTypeWithQualityHeaderValue("application/json"));
var product = new Product() { Name = txtProd.Text Price = txtPrice.Text, Category = txtcat.Text };
var response = await client.PostAsJsonAsync("products", product); // here //products is the controller(Endpoint) name
}
for creating api follow my article :- https://www.sharpencode.com/article/WebApi/implementing-crud
Srinivasan RamamoorthiRank #877 · 2.5K reputationPosted Oct 28, 2021, 9:24 AM EDT