473,386 Members | 1,785 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Filling in HttpWebRequest object with form data

I am looking to post to a banking site form data in process to do with a checkout

I see that the HttpWebRequest object can befilled with header information and form data so that programmatically i can post form data and then process the HttpWebResponse however, I cannot find any examples of how to fill that object with the form data I need to submit

Does anyone know of any site listing example strings of form data so that I can see how to post the name/value pairs

Much thank
Erik
Nov 18 '05 #1
3 3625
the post data format is:

<fieldName>=<value>&<fieldName>=<value>

the value should be url encoded, not html or xml.

example:

value1=hello&value2=hello%20there

be sure to set the header type form encoded

-- bruce (sqkwork.com)
"Erik Jensen" <ej@webland.ca> wrote in message
news:83**********************************@microsof t.com...
I am looking to post to a banking site form data in process to do with a checkout.
I see that the HttpWebRequest object can befilled with header information and form data so that programmatically i can post form data and then process
the HttpWebResponse however, I cannot find any examples of how to fill that
object with the form data I need to submit.
Does anyone know of any site listing example strings of form data so that I can see how to post the name/value pairs?
Much thanks
Erik

Nov 18 '05 #2
Thanks. So to clarify. If i were to write something like the following, would that be on the right track

string postData="FirstFormField=" + FirstFormVariable +"&SecondFormField=" + SecondFormFiel
ASCIIEncoding encoding=new ASCIIEncoding()
byte[] byte1=encoding.GetBytes(postData)

myHttpWebRequest.ContentType="application/x-www-form-urlencoded"

myHttpWebRequest.ContentLength=postData.Length
Stream newStream=myHttpWebRequest.GetRequestStream()

//Then parse the response somehow

Nov 18 '05 #3
almost:

string postData = string.Format("FirstFormField={0}&SecondFormField= {1}",
HttpUtility.UrlEncode(FirstFormField),
HttpUtility.UrlEncode(SecondFormField));

the response will be returned html, that you need to parse.

-- bruce (sqlwork.com)

"Erik Jensen" <an*******@discussions.microsoft.com> wrote in message
news:26**********************************@microsof t.com...
Thanks. So to clarify. If i were to write something like the following, would that be on the right track?
string postData="FirstFormField=" + FirstFormVariable +"&SecondFormField=" + SecondFormField ASCIIEncoding encoding=new ASCIIEncoding();
byte[] byte1=encoding.GetBytes(postData);

myHttpWebRequest.ContentType="application/x-www-form-urlencoded";

myHttpWebRequest.ContentLength=postData.Length;
Stream newStream=myHttpWebRequest.GetRequestStream();

//Then parse the response somehow?

Nov 18 '05 #4

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

Similar topics

10
by: Gregory A Greenman | last post by:
I'm trying to write a program in vb.net to automate filling out a series of forms on a website. There are three forms I need to fill out in sequence. The first one is urlencoded. My program is...
8
by: Du | last post by:
I'm trying to automate the upload process to yousendit.com, but the file size doesn't add up and yousendit.com keep rejecting my upload (it accepts the upload until the very end) I don't know...
1
by: LD | last post by:
Hi, I'm pulling my hair out!! My problem is, I need to automatically upload a zip file along with 3 other pieces of text data to a web server and wait for it's xml response. Basically a...
6
by: Saket Mundra | last post by:
I have a web application with two forms. After user enters data in first form he is directed to the second form. After Filling the second form as he clicks on save button, the data entered is...
7
by: Mark Waser | last post by:
Hi all, I'm trying to post multipart/form-data to a web page but seem to have run into a wall. I'm familiar with RFC 1867 and have done this before (with AOLServer and Tcl) but just can't seem...
4
by: hharry | last post by:
Hi All, I have a simple web service: <WebMethod()> _ Public Function ReSample(ByVal sInput As Integer) As String
3
by: JansenH | last post by:
We have implemented a 'HTTP Post' client in C# that posts Xml documents to a webserver. This is working fine if the post rate is one post for every 20 seconds. But if the post rate is increased to...
0
by: dattaforit | last post by:
I am using VC++ .Net (2003). In my application i create a HttpWebRequest object, add the method and header to the request. An now try to get the response. I get the response. to get the response i...
0
by: scottf35 | last post by:
Hi, I am working on (read that - upgrading) an application. This application creates an HTTPWebRequest object, populates it with values which are then sucked out of the Request.Form object (eg...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

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.