Project

General

Profile

Upload attachment - POST, C#, RestSharp

Added by Matteo Cominetti about 11 years ago

I'm developing a C# app that uses Redmine REST API, it uses RestSharp Client for JSON calls. All other REST calls I make work fine but I cannot find a way to upload attachments. I've widely searched the web and tried many solutions but nothing worked.
The code actually looks like: http://pastebin.com/3Q8SLnwg

If I execute it above nothing happens and the response is empty with error "Not Acceptable". If I remove line 8 (the AddBody), it actually works but of course nothing is uploaded, JSON response: {
"upload": {
"token": "11."
}
}

So actually, the real question is what to punt in AddBody() to send the file as application/octet-stream. Since RestSharp also has a request.AddFile() method, I tried it too in different ways but nothing...

Any help much appreciated!


    (1-1/1)