473,563 Members | 2,695 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to create multipart HTTP request using HttpWebRequest

Hi,

I need to create a multipart request to UPS manifest upload electronic
service. UPS wants the request to consist of a series of headers and
bodies, and its not clear how can I use the HttpWebRequest object to do
this. there is the Headers collection, but I don't think it will give
me the control we need.

is there a low-level way to create the entire stream and attach to the
object before posting ?

this is the requirement for the request from UPS: notice it has the
first header, specifying Multipart and a boundry defined by the work
BOUNDRY.with a total length of 1040

then you have the first boundry, with length=140, the actual content
for this boundry, then another boundry ...

=============== =============== ==============
POST /hapld/tos/kdwhapltos HTTP/1.1<cr/lf>
Host: www.pld-certify.ups.com <cr/lf>
Content-type: multipart/mixed; boundary=BOUNDA RY<cr/lf>
Content-length: 1040<cr/lf>
<cr/lf>
--BOUNDARY<cr/lf>
Content-type: application/x-www-form-urlencoded<cr/lf>
Content-length: 140<cr/lf>
<cr/lf>
AppVersion=1.0& AcceptUPSLicens eAgreement=Yes& ResponseType=ap plication/x-ups-pld&VersionNumb er=
V4R1&UserId=use ridvalue&Passwo rd=passwordvalu e<cr/lf>
<cr/lf>
--BOUNDARY<cr/lf>
Content-type: application/x-ups-binary<cr/lf>
Content-length: 719<cr/lf>
<cr/lf>
020082 2.0 200210170000000 0000010500 000000001*AA0A1 754 US
123456700200000 1*BA1z123456010 0002352 00001+000000000 0000010 +000
0000000000000LB S01PRE10 3INUSD000001*CA 18ATTENTION
DELIVERY 234 SOME LOCAL ST SO
ME CITY NJ 07652 US12015551212 *PA1z1234560100 002352
02+0000010 +0000010
*SA000004<cr/lf>
<cr/lf>
--BOUNDARY--<cr/lf>

Jan 11 '07 #1
4 5312
Hello,

have you tried to set the HttpWebRequest. SendChunked to true?

Best regards,
Henning Krause

<yo**********@s tructuredweb.co mwrote in message
news:11******** *************@p 59g2000hsd.goog legroups.com...
Hi,

I need to create a multipart request to UPS manifest upload electronic
service. UPS wants the request to consist of a series of headers and
bodies, and its not clear how can I use the HttpWebRequest object to do
this. there is the Headers collection, but I don't think it will give
me the control we need.

is there a low-level way to create the entire stream and attach to the
object before posting ?

this is the requirement for the request from UPS: notice it has the
first header, specifying Multipart and a boundry defined by the work
BOUNDRY.with a total length of 1040

then you have the first boundry, with length=140, the actual content
for this boundry, then another boundry ...

=============== =============== ==============
POST /hapld/tos/kdwhapltos HTTP/1.1<cr/lf>
Host: www.pld-certify.ups.com <cr/lf>
Content-type: multipart/mixed; boundary=BOUNDA RY<cr/lf>
Content-length: 1040<cr/lf>
<cr/lf>
--BOUNDARY<cr/lf>
Content-type: application/x-www-form-urlencoded<cr/lf>
Content-length: 140<cr/lf>
<cr/lf>
AppVersion=1.0& AcceptUPSLicens eAgreement=Yes& ResponseType=ap plication/x-ups-pld&VersionNumb er=
V4R1&UserId=use ridvalue&Passwo rd=passwordvalu e<cr/lf>
<cr/lf>
--BOUNDARY<cr/lf>
Content-type: application/x-ups-binary<cr/lf>
Content-length: 719<cr/lf>
<cr/lf>
020082 2.0 200210170000000 0000010500 000000001*AA0A1 754 US
123456700200000 1*BA1z123456010 0002352 00001+000000000 0000010 +000
0000000000000LB S01PRE10 3INUSD000001*CA 18ATTENTION
DELIVERY 234 SOME LOCAL ST SO
ME CITY NJ 07652 US12015551212 *PA1z1234560100 002352
02+0000010 +0000010
*SA000004<cr/lf>
<cr/lf>
--BOUNDARY--<cr/lf>
Jan 11 '07 #2
thanks for the answer!

how would SendChunked alter the control over the request ? it seems
only relevant to allow breaking of large requests into multiple, but no
fine control over logical sections, which is what I need.

there seems to be no support for Multipart with this class. do you
think I can create only the top-level headers, and then prepare
everything else as one content, including the second "content-type" and
"content-length" sections ?

Henning Krause [MVP - Exchange] wrote:
Hello,

have you tried to set the HttpWebRequest. SendChunked to true?

Best regards,
Henning Krause

<yo**********@s tructuredweb.co mwrote in message
news:11******** *************@p 59g2000hsd.goog legroups.com...
Hi,

I need to create a multipart request to UPS manifest upload electronic
service. UPS wants the request to consist of a series of headers and
bodies, and its not clear how can I use the HttpWebRequest object to do
this. there is the Headers collection, but I don't think it will give
me the control we need.

is there a low-level way to create the entire stream and attach to the
object before posting ?

this is the requirement for the request from UPS: notice it has the
first header, specifying Multipart and a boundry defined by the work
BOUNDRY.with a total length of 1040

then you have the first boundry, with length=140, the actual content
for this boundry, then another boundry ...

=============== =============== ==============
POST /hapld/tos/kdwhapltos HTTP/1.1<cr/lf>
Host: www.pld-certify.ups.com <cr/lf>
Content-type: multipart/mixed; boundary=BOUNDA RY<cr/lf>
Content-length: 1040<cr/lf>
<cr/lf>
--BOUNDARY<cr/lf>
Content-type: application/x-www-form-urlencoded<cr/lf>
Content-length: 140<cr/lf>
<cr/lf>
AppVersion=1.0& AcceptUPSLicens eAgreement=Yes& ResponseType=ap plication/x-ups-pld&VersionNumb er=
V4R1&UserId=use ridvalue&Passwo rd=passwordvalu e<cr/lf>
<cr/lf>
--BOUNDARY<cr/lf>
Content-type: application/x-ups-binary<cr/lf>
Content-length: 719<cr/lf>
<cr/lf>
020082 2.0 200210170000000 0000010500 000000001*AA0A1 754 US
123456700200000 1*BA1z123456010 0002352 00001+000000000 0000010 +000
0000000000000LB S01PRE10 3INUSD000001*CA 18ATTENTION
DELIVERY 234 SOME LOCAL ST SO
ME CITY NJ 07652 US12015551212 *PA1z1234560100 002352
02+0000010 +0000010
*SA000004<cr/lf>
<cr/lf>
--BOUNDARY--<cr/lf>
Jan 11 '07 #3
Hello,

I would guess, yes.
As for the SendChunked - If set to true, the data is automatically sent in
chunks as per RFC 2616
(http://www.w3.org/Protocols/rfc2616/...html#sec3.6.1).
But you can't control the chunksize here...

Best regards,
Henning Krause

<yo**********@s tructuredweb.co mwrote in message
news:11******** *************@k 58g2000hse.goog legroups.com...
thanks for the answer!

how would SendChunked alter the control over the request ? it seems
only relevant to allow breaking of large requests into multiple, but no
fine control over logical sections, which is what I need.

there seems to be no support for Multipart with this class. do you
think I can create only the top-level headers, and then prepare
everything else as one content, including the second "content-type" and
"content-length" sections ?

Henning Krause [MVP - Exchange] wrote:
>Hello,

have you tried to set the HttpWebRequest. SendChunked to true?

Best regards,
Henning Krause

<yo**********@ structuredweb.c omwrote in message
news:11******* **************@ p59g2000hsd.goo glegroups.com.. .
Hi,

I need to create a multipart request to UPS manifest upload electronic
service. UPS wants the request to consist of a series of headers and
bodies, and its not clear how can I use the HttpWebRequest object to do
this. there is the Headers collection, but I don't think it will give
me the control we need.

is there a low-level way to create the entire stream and attach to the
object before posting ?

this is the requirement for the request from UPS: notice it has the
first header, specifying Multipart and a boundry defined by the work
BOUNDRY.with a total length of 1040

then you have the first boundry, with length=140, the actual content
for this boundry, then another boundry ...

=============== =============== ==============
POST /hapld/tos/kdwhapltos HTTP/1.1<cr/lf>
Host: www.pld-certify.ups.com <cr/lf>
Content-type: multipart/mixed; boundary=BOUNDA RY<cr/lf>
Content-length: 1040<cr/lf>
<cr/lf>
--BOUNDARY<cr/lf>
Content-type: application/x-www-form-urlencoded<cr/lf>
Content-length: 140<cr/lf>
<cr/lf>
AppVersion=1.0& AcceptUPSLicens eAgreement=Yes& ResponseType=ap plication/x-ups-pld&VersionNumb er=
V4R1&UserId=use ridvalue&Passwo rd=passwordvalu e<cr/lf>
<cr/lf>
--BOUNDARY<cr/lf>
Content-type: application/x-ups-binary<cr/lf>
Content-length: 719<cr/lf>
<cr/lf>
020082 2.0 200210170000000 0000010500 000000001*AA0A1 754 US
123456700200000 1*BA1z123456010 0002352 00001+000000000 0000010 +000
0000000000000LB S01PRE10 3INUSD000001*CA 18ATTENTION
DELIVERY 234 SOME LOCAL ST SO
ME CITY NJ 07652 US12015551212 *PA1z1234560100 002352
02+0000010 +0000010
*SA000004<cr/lf>
<cr/lf>
--BOUNDARY--<cr/lf>
Jan 11 '07 #4

its actually working! I create one long string that contains all the
secondary boundries , each with its own content-type and content-length
headers. most of the complexity stems from having to calculate the
total length to put in the initial content-length header. I wonder if
this is a specific UPS requirement or part of the protocol RFC, but oh
well, it can't hurt and its working!

the trick is to add correctly the lengths of al the various parts so
the content-length

Henning Krause [MVP - Exchange] wrote:
Hello,

I would guess, yes.
As for the SendChunked - If set to true, the data is automatically sent in
chunks as per RFC 2616
(http://www.w3.org/Protocols/rfc2616/...html#sec3.6.1).
But you can't control the chunksize here...

Best regards,
Henning Krause

<yo**********@s tructuredweb.co mwrote in message
news:11******** *************@k 58g2000hse.goog legroups.com...
thanks for the answer!

how would SendChunked alter the control over the request ? it seems
only relevant to allow breaking of large requests into multiple, but no
fine control over logical sections, which is what I need.

there seems to be no support for Multipart with this class. do you
think I can create only the top-level headers, and then prepare
everything else as one content, including the second "content-type" and
"content-length" sections ?

Henning Krause [MVP - Exchange] wrote:
Hello,

have you tried to set the HttpWebRequest. SendChunked to true?

Best regards,
Henning Krause

<yo**********@s tructuredweb.co mwrote in message
news:11******** *************@p 59g2000hsd.goog legroups.com...
Hi,

I need to create a multipart request to UPS manifest upload electronic
service. UPS wants the request to consist of a series of headers and
bodies, and its not clear how can I use the HttpWebRequest object to do
this. there is the Headers collection, but I don't think it will give
me the control we need.

is there a low-level way to create the entire stream and attach to the
object before posting ?

this is the requirement for the request from UPS: notice it has the
first header, specifying Multipart and a boundry defined by the work
BOUNDRY.with a total length of 1040

then you have the first boundry, with length=140, the actual content
for this boundry, then another boundry ...

=============== =============== ==============
POST /hapld/tos/kdwhapltos HTTP/1.1<cr/lf>
Host: www.pld-certify.ups.com <cr/lf>
Content-type: multipart/mixed; boundary=BOUNDA RY<cr/lf>
Content-length: 1040<cr/lf>
<cr/lf>
--BOUNDARY<cr/lf>
Content-type: application/x-www-form-urlencoded<cr/lf>
Content-length: 140<cr/lf>
<cr/lf>
AppVersion=1.0& AcceptUPSLicens eAgreement=Yes& ResponseType=ap plication/x-ups-pld&VersionNumb er=
V4R1&UserId=use ridvalue&Passwo rd=passwordvalu e<cr/lf>
<cr/lf>
--BOUNDARY<cr/lf>
Content-type: application/x-ups-binary<cr/lf>
Content-length: 719<cr/lf>
<cr/lf>
020082 2.0 200210170000000 0000010500 000000001*AA0A1 754 US
123456700200000 1*BA1z123456010 0002352 00001+000000000 0000010 +000
0000000000000LB S01PRE10 3INUSD000001*CA 18ATTENTION
DELIVERY 234 SOME LOCAL ST SO
ME CITY NJ 07652 US12015551212 *PA1z1234560100 002352
02+0000010 +0000010
*SA000004<cr/lf>
<cr/lf>
--BOUNDARY--<cr/lf>
Jan 12 '07 #5

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

Similar topics

0
273
by: darin dimitrov | last post by:
I am looking for an implementation of a multipart content parser for ..NET (http://www.faqs.org/rfcs/rfc2388.html). I suppose that the HttpWebRequest class uses such a parser in order to extract the parameters and uploaded files from the request stream. Correct me if I am wrong but these classes are intended for an internal of the framework....
10
19322
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 able to fill that one out just fine. The second form is multipart/form-data. Unfortunately, I haven't been able to fill that out in a way that makes...
3
26092
by: NextOne | last post by:
Hi ! Is it possible to send an AJAX XMLHttpRequest using prototype.js API for a multipart/form-data ? I already done parsing form parameters and sending GET/POST request, but does this work with <input type="file"> ? Who handle file submit and encoding ? regards,
4
1951
by: Bob | last post by:
I've got to use the http protocol to communicate with another machine as part of a Web Service using HttpWebRequest and HttpWebResponse. As such, timing is important. When I create the HttpWebRequest as shown in the help example: Dim myReq As HttpWebRequest = _ WebRequest.Create("http://www.contoso.com/") does this actually go out and...
0
1052
by: Luis Esteban Valencia | last post by:
Hello. I got this message <ns0:Orden xmlns:ns0="http://localhost/CreditCheck"> <IdCliente>10</IdCliente> - <Pedido> <IdProducto>IdProducto_0</IdProducto> <Cantidad>10.4</Cantidad> <PrecioUnitario>10.4</PrecioUnitario> </Pedido> <Estado>Estado_0</Estado>
3
9573
by: eSolTec, Inc. 501(c)(3) | last post by:
Thank you in advance for any and all assistance. I'm trying to create a call to a web page to validate and register software. The code I'm using is: Private Sub OK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK.Click Dim WebRequest As HttpWebRequest Dim instance As HttpWebRequest =...
6
32729
by: Boldgeek | last post by:
I am trying to develop an app that will allow automatic updating of a web form which uses multipart/form-data enctype (as it MIGHT be sending an image) I have an example form, which when submitted displays the results as you would expect. However when I send the same data using the PHP script I get a 400 error: Bad Request
0
2772
by: sachintandon | last post by:
Hello all, Thanks in advance for your help I have a problem in sending emails, my requirement is to send multipart alternative emails with attachments, I'm able to send text with attachments or HTML mails with attachments, but some mail clients are not able to display the html mails that is why I need to send multipart alternative emails, when I...
2
3170
by: karthickdevi | last post by:
Hi, I am developing a Desktop Application in VB .Net to upload files to the server. I need to encrypt the contents and upload it to the server. I am supposed to use enctype=multipart/form-data . I searched the web and i get examples only for ASP .Net. I want to use only VB .Net Can anyone help me ?
0
7583
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8106
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7638
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7948
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6250
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
3642
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3626
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1198
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
923
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.