Post request with "application/x-www-form-urlencoded" in C#

http

Here is an example in c# with HttpClient to send a key value form content with the default HttpClient


List<KeyValuePair<string, string>> nvc = new ();
nvc.Add(new KeyValuePair<string, string>("Input1", "TEST2"));
nvc.Add(new KeyValuePair<string, string>("Input2", "TEST2"));
using HttpClient client = new ();
using HttpRequestMessage req = new (HttpMethod.Post, url) { Content = new FormUrlEncodedContent(nvc) };
using var res = await client.SendAsync(req);

Post a Comment

Previous Post Next Post