472,993 Members | 2,191 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,993 software developers and data experts.

post programmatically

Hi

I want to programmatically perform a post. Can some one please give me
some pointers to which classes I need to use to achieve this?

The form which is normally posted from the website looks like the
following, but I want to do it programmatically.
<form action="https://intl.payments/recdpay" method="POST"
target="_top">
<input type="hidden" name="merchantID" value="xx7223.189" />
<input type="hidden" name="orderID" value="UK_Z0000287" />
<input type="hidden" name="amount" value="59995" />
<input type="hidden" name="currencyCode" value="GBP" />
<input type="hidden" name="cardType" value="6" />
<input type="submit" value="Pay" />
</form>

Thanks,
Peter
Sep 3 '08 #1
3 2245

"Peter" <xd****@hotmail.comwrote in message
news:ux**************@TK2MSFTNGP05.phx.gbl...
Hi

I want to programmatically perform a post. Can some one please give me
some pointers to which classes I need to use to achieve this?

The form which is normally posted from the website looks like the
following, but I want to do it programmatically.
HttpWebRequest should do the trick, just don't forget to set its Method to
"POST". Values of form controls go into the request body, which is just a
stream for WebRequest, so you'll need to format it yourself. W3C HTML 4.01
spec has detailed description of the format:

http://www.w3.org/TR/html4/interact/forms.html#h-17.13
Sep 3 '08 #2
On Sep 3, 6:16*pm, "Peter" <xdz...@hotmail.comwrote:
Hi

I want to programmatically perform a post. Can some one please give me
some pointers to which classes I need to use to achieve this?

The form which is normally posted from the website looks like the
following, but I want to do it programmatically.

<form action="https://intl.payments/recdpay" method="POST"
target="_top">
<input type="hidden" name="merchantID" value="xx7223.189" />
<input type="hidden" name="orderID" value="UK_Z0000287" />
<input type="hidden" name="amount" value="59995" />
<input type="hidden" name="currencyCode" value="GBP" />
<input type="hidden" name="cardType" value="6" />
<input type="submit" value="Pay" />
</form>

Thanks,
Peter
As Pavel Minaev said, HttpWebRequest would be good enough. But
WebRequest is also good, I think. Basically, as far as I know,
HttpWebRequest is a superset of WebRequest. You can find many samples
for it, even the .NET documentation had a section about how to POST a
request at the How do I section.

To save your time, I will write a quick code for you, may contain some
errors, but you can start it from there.

WebRequest req = WebReqest.Create("https://....");
req.Method="POST"; <-Default is GET, so need to specify "POST"
req.ContentType="application/x-www-form-urlencoded"; <-This is
required because there are other types of forms like multipart or
something.
Stream s = req.GetRequestStream();
string data="merchantID=xx7223.189&orderID....";
byte[] binaryData=Encoding.UTF8.GetBytes(data); <-Supposing the page's
encoding is UTF-8. Need to change it in other cases.
s.Write(binaryData,0,binaryData.Length);
s.close();
req.ContentLength=binaryData.Length;
WebResponse res =req.GetResponse();
Sep 3 '08 #3
"Sin Jeong-hun" <ty*******@gmail.comwrote in message
news:1d**********************************@z11g2000 prl.googlegroups.com...
On Sep 3, 6:16 pm, "Peter" <xdz...@hotmail.comwrote:
As Pavel Minaev said, HttpWebRequest would be good enough. But
WebRequest is also good, I think. Basically, as far as I know,
HttpWebRequest is a superset of WebRequest. You can find many samples
for it, even the .NET documentation had a section about how to POST a
request at the How do I section.
WebRequest is an abstract class, HttpWebRequest is one specific
implementation.

It is generally advised to use WebRequest.Create() factory method to
instantiate any implementation of WebRequest. But it is explicitly allowed
to cast the return value of WebRequest.Create() to the specific type you
expect to get.

In this case though, I've missed the fact that WebRequest has property
Method already (strange, since it's really HTTP-specific, and cannot be
properly used in a generic fashion anyway), so no need for cast.
Sep 4 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Dan Greenblatt | last post by:
I am trying to programmatically manipulate the menus in my application, for purposes of a tutorial, showing users where things are in our application's menu interface. My goal is to be able to...
1
by: DM | last post by:
I have a user control that contains a DropDownList and a Submit Button. In the Page_Load method of the User Control, I populate the Drop Down List. When the user clicks on the submit button, I need...
6
by: Ben | last post by:
Hi I need to design a form that I can programmatically post using this code from a VB .NET Windows Application: Dim web As New System.Net.WebClient() web.Headers.Add("Content-Type",...
3
by: WJ | last post by:
1. How can I use POST method to post the following XML statements to an Html page or Asp page using Asp.net or 2. If the XML below is a file (text), how do I POST it to other web site...
7
by: | last post by:
Hello, I would like to do the following from a asp.net button click: <form method="POST" action="https://www.1234.com/trans_center/gateway/direct.cgi"> <input type="hidden" name="Merchant"...
8
by: Gert | last post by:
Hi, I have a form (server side) because of the filling of variables through the application. But now I need to post it to an url on submit. My .HTML form looks like this, but how to translate it...
4
by: David Veeneman | last post by:
I want to programmatically create some POST data on a web server, then pass that data to another web page that the server calls, using Server.Transfer(). What's the best way to do that? I'm...
7
JodiPhillips
by: JodiPhillips | last post by:
Hi, My first post! I've basically taught myself Access and the little I know about VBA through reading these forums and a couple of books. I'm in the middle of a project at work - to put it...
2
by: David | last post by:
Hello, I would like to know how to post form data programmatically. The idea is to get the intranet web page, programmatically entre the username and password in a login form, post it and be...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
3
SueHopson
by: SueHopson | last post by:
Hi All, I'm trying to create a single code (run off a button that calls the Private Sub) for our parts list report that will allow the user to filter by either/both PartVendor and PartType. On...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.