Click here to Skip to main content
15,905,616 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
Hi,
I have a POST web service that requires image as the post body with MIME type specification.


I am sending an image
http://media.stacksbowers.com/4130/3030/3030/3031/3232/35/A0000001225-uscoin-zoom-1.JPG


But the response shows

{"error":{"message":"Posting images with MIME types other than image/jpeg, image/png, and image/gif is not supported","class":"SIMPLE-ERROR","superclasses":["SIMPLE-CONDITION","ERROR"]}}

This is the code I am using.



C#
var client33 = new RestClient("https://uat2-server.auctionmobility.com/v1/auction-lot/1-TPRZ/image?access_token=1-1-87857099-8ec5-4c4a-836c-abf8cf1c6728");
var request = new RestRequest(Method.POST);
request.AddHeader("content-type", "multipart/form-data");
request.AddParameter("multipart/form-data", "Content-Disposition:                    form-data;name=\"image[]\"; filename=\"A0000098522-uscoin-thumb-1-0.JPEG\"Content-Type: image/jpeg", ParameterType.RequestBody);
request.AddParameter("image[]", Convert.ToBase64String(imageBytes));
IRestResponse response33 = client33.Post(request);




imageBytes is the byte array of image
Posted
Updated 17-Sep-15 5:25am
v2
Comments
F-ES Sitecore 14-Sep-15 4:19am    
It might be the case of JPG in the url. Try using jpg instead.
Baiju christadima 14-Sep-15 4:35am    
Thanks,
But I had tried jpg too, it still showing the same error.

1 solution

-Get the image as byte array and then convert it to base64 string.
-Send the image through the web service
-Do the opposite on the other side to get back the image data.
-Then you can save the image to disk or in db
 
Share this answer
 
Comments
Krunal Rohit 17-Sep-15 7:25am    
Yeah!

-KR

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900