How to send x-www-form-urlencoded in a post request in webclient?

SkrtOnDiscord

I know I can send json but I couldn't find how to send x-www-form-urlencoded. I don't know what to try as I couldn't find anything.

WebClient wc = new WebClient();


string data = "channel_id=+12039273888&channel_type=phone&channel_verification=514950";

wc.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";

string result = wc.UploadString("http://3.86.171.88/api/login", data);

System.Console.WriteLine(result);
Rahul

You can use UploadString() method on WebClient class like

string data = "name=john&age=20&city=Uganda";
using (WebClient client = new WebClient())
{
    client.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";
    string result = client.UploadString(url of api resource, data);
}

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Spring - wrong encoding POST request with x-www-form-urlencoded

How to send post request with x-www-form-urlencoded body

Post a x-www-form-urlencoded request from React Native

Why does Axios send my POST request with Content-Type application/x-www-form-urlencoded when using a string as the request body?

RestSharp post request - Body with x-www-form-urlencoded values

Jersey client Post Request with x-www-form-urlencoded Fails

Send sensitive data using POST+application/x-www-form-urlencoded

How to send urlencoded parameters in POST request in python

Swift - How to send POST request with "x-www-form-urlencoded" content-type

Swift 4 send POST request as x-www-form-urlencoded

cURL send JSON as x-www-form-urlencoded

Postman x-www-form-urlencoded returns null value for a POST request even though the input field is filled

How to send bearer token and x-www-form-urlencoded data using Node Request

How to POST content as application/x-www-form-urlencoded

How to POST x-www-form-urlencoded in retrofit

How to send a POST request with Content-Type "application/x-www-form-urlencoded"

How to correctly send application/x-www-form-urlencoded in Angular post call

How to post request with spring boot web-client for Form data for content type application/x-www-form-urlencoded

How to send post request with content-type x-www-form-urlencoded android retrofit

Node.js Axios POST request with application/x-www-form-urlencoded format?

PYTHON: requests.post() how to send request_body encoded as application/x-www-form-urlencoded

How test Post request with custom object in content type application/x-www-form-urlencoded?

How to send post request with x-www-form-urlencoded body with loopj-async-http library

How to convert x-www-form-urlencoded post Message to JSON post Message?

why can't Volley String request send Body parameters with POST method in x-www-form-urlencoded?

how to post body x-www-form-urlencoded using webclient?

How to do a post request using FORM-DATA or x-www-form-urlencoded with Android?

Making a MarkLogic xdmp:http-post() request with x-www-form-urlencoded request body

How to sent Http POST request with application/x-www-form-urlencoded