Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to pass json value to API using post in c#?

I am new to c#,can you tell me what is best way to pass json value to API in c# using POST.

Below I have written python code, but not sure how to do it in c#.

string payload = {
   "username" : "1432143352759a61bca0ad4a35a4f0", # when you register, they'll return this
   "password" : "password",
   "client_id" : "c3ca1565b0dbedd74c5c",
   "client_secret" : "e0591fe41c4e2585b313ad93e2748022db3186d0",
}

res = requests.post("https://sandbox.synapsepay.com/api/v2/user/login", payload)
print res.status_code
print res.text
like image 757
nikunjM Avatar asked Nov 18 '25 14:11

nikunjM


1 Answers

From a .NET client (e.g WinForm), you can use HttpClient.

Check out this solution:
http://www.asp.net/web-api/overview/advanced/calling-a-web-api-from-a-net-client

like image 144
Carl Prothman Avatar answered Nov 21 '25 04:11

Carl Prothman



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!