Domanda

I need to send to Web Service a POST request with body that is represented as "multipart/form-data" Content-type.

The sample of the body is the following:

Content-Type:multipart/form-data; boundary=WebBoundary

--WebBoundary
Content-Disposition: form-data; name="Key#1"
Value#1

--WebBoundary
Content-Disposition: form-data; name="Key#2"
Value#2

--WebBoundary
Content-Disposition: form-data; name="FileKey"; filename="file.jpg"
Content-Type: image/png

--WebBoundary--

How can I construct MIME message for this use case using HttpWebRequest? I want also to customize data I send. For example at first I send 3 keys where 2 keys are strings and one is image, and other time I want to send 5 keys of image type. Anyway I didn't find in .NET library how to do it.

If anyone has a solution for this, I'll appreciate it.

Thank you in advance.

È stato utile?

Soluzione

At the end I had to make my own solution. And the following article helped me with this: http://www.paraesthesia.com/archive/2009/12/16/posting-multipartform-data-using-.net-webrequest.aspx

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top