How to create a batch(multipart/mixed) with boundary in c# using HttpWebRequest

Viewed 863

I'm trying to create a batch(multipart/mixed) with boundary in c# using HttpWebRequest but always it returns an error :

"The batch request must have a boundary specification in the \"Content-Type\" header."

if I remove the boundary the error is the same but about boundary. Could anyone create a little example of it?

My data is

--batch
Content-Type: multipart/mixed;boundary=changeset
--changeset
Content-Type: application/http
Content-Transfer-Encoding: binary 
Content-ID: 1
--changeset
PUT     
https://api.channeladvisor.com/v1/Products(20199461)/Images('ImageFree1')?
access_token=-qK4l1JoGct6BMFXGY6t24VHbaCNpXMFsqns6QioOwE-15035
Content-type: application/json\r\n{\"Url\":\"http://iguanasell-
pics.com/photos/021G/cat/Montegrappa-Ducale-Ballpoint-pen-Mother-of-
Pearl-Resin-Rose-gold-trim-1.jpg\"}
--changeset-- 
--batch--

And my code:

String token= "abcd1234";
var requestMulti = 
HttpWebRequest.Create("https://api.channeladvisor.com/v1/$batch?
access_token=" + token);
requestMulti.ContentType = "multipart/mixed;boundary=changeset";
requestMulti.Method = "POST";`

Thanks!

0 Answers
Related