Post errors

N

neoret

I don't get any further on this - pleas help me :)

In c# I'm using the httpWebRequest object to post a word-document along
with some parameters to a server. My challenges are:

1. When creating the requestStream object and write to it the message
is posted without the
credentials. I get an unauthorized error from the server: HTTP/1.1
401 Unauthorized.

2. When I ask for the response on the requesobject (httpWebResponse =
HttpWebResponse)
httpWebRequest.GetResponse(); --> this time the credentials are
posted as well and I get
another error from the server: HTTP/1.1 500
Multipart+request+expected

Why does my code post two times??
What does the multipart+request+expected error mean??

I'll be very greatfull for any contribution!

neoret
 
K

Kevin Spencer

When you use an HTTP Post request to upload a file, the Request must have an
enctype of "multipart/form-data". In addition, there must be a boundary
identifying the file(s) to be uploaded. The binary data must be
Base64-encoded. It's rather complex. See the following RFCs for more
information:

http://www.faqs.org/rfcs/rfc1867.html
http://www.faqs.org/rfcs/rfc1521.html
http://www.faqs.org/rfcs/rfc1522.html

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

Hard work is a medication for which
there is no placebo.
 
J

Joerg Jooss

Thus wrote Kevin,
When you use an HTTP Post request to upload a file, the Request must
have an enctype of "multipart/form-data". In addition, there must be a
boundary identifying the file(s) to be uploaded. The binary data must
be Base64-encoded. It's rather complex. See the following RFCs for
more information:

http://www.faqs.org/rfcs/rfc1867.html
http://www.faqs.org/rfcs/rfc1521.html
http://www.faqs.org/rfcs/rfc1522.html

Note that WebClient.UploadFile() implements "multipart/form-data" encoded
requests.

Cheers,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top