Uploading images from .Net

GeordieGeordie Member Posts: 1

I have been trying to upload images to the item object for a while, and not getting very far.  Most of the guidance appears to be in php rather than .Net.  In the past I have been able to use the info I get from Postman and convert it to what I need for .Net. Unfortunately even this approach has not resulted in a solution.

I did try using RestSharp and leverage Postman's code snippet, but that didn't work either.

The error that I'm currently getting is: "httpCode":"405","httpMessage":"Method Not Allowed","message":"PUT, POST require an input body."

Postman code:
var request = new RestRequest(Method.POST);

request.AddHeader("Postman-Token", "cfacab1e-1023-48ba-aaac-093fe3699c3b");
request.AddHeader("Cache-Control", "no-cache");
request.AddHeader("Authorization", "bearer d0a73757ae6668365658ddef34744f74dbcb9cbc0");
request.AddHeader("content-type", "multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW");

request.AddParameter("multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW", "------WebKitFormBoundary7MA4YWxkTrZu0gWContent-Disposition: form-data; name=\"data\"<?xml version=\"1.0\"?> <Image> <description>Shayfak</description><filename>Shayfak.jpg</filename><ordering>1</ordering><size>2</size> <itemID>1493</itemID> </Image>------WebKitFormBoundary7MA4YWxkTrZu0gWContent-Disposition: form-data; name=\"image\"; filename=\"C:\\Users\\marti\\Pictures\\Shayfak.jpg\"Content-Type: image/jpg------WebKitFormBoundary7MA4YWxkTrZu0gW--", ParameterType.RequestBody);

IRestResponse response = client.Execute(request);

Any help would be much appreciated.



Sign In or Register to comment.