0

Our third party payment gateway provider only supports the FORM POST for handshake, payment and payment verification etc.

For this we need to perform a POST from C#.NET. Could someone help me whether there's any NUGET Packages or samples to achieve this?

I had a look at this already but did not find elegant:

Jenish Rabadiya
  • 6,708
  • 6
  • 33
  • 62
Nil Pun
  • 17,035
  • 39
  • 172
  • 294

1 Answers1

1

One easy way is to use RestSharp.

This is a sample POST request.

using RestSharp;

var client = new RestClient("http://example.com");
// client.Authenticator = new HttpBasicAuthenticator(username, password);

var request = new RestRequest("resource/{id}", Method.POST);
request.AddParameter("name", "value"); 
request.AddUrlSegment("id", "123"); 
// easily add HTTP Headers
request.AddHeader("header", "value");

// add files to upload (works with compatible verbs)
request.AddFile(path);

// execute the request
RestResponse response = client.Execute(request);
Karthik Nishanth
  • 2,000
  • 1
  • 22
  • 28
  • Per my post, it's not a REST or SOAP service. It's just aspx page which accepts form post. For initial hand shake we need to post data via code. – Nil Pun Apr 24 '15 at 02:47