Upload file via POST call with C#, RestSharp

Added by Sayan Paul about 4 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!