I have been using AddParameter
to include XML bodies in my HTTP requests:
request.AddParameter(contentType, body, ParameterType.RequestBody);
However, this does not seem to work for non-string bodies. (RestSharp's Http.RequestBody
is a string for some reason.) I tried using AddFile()
, but I can't find any way to avoid encoding the "file" as multipart/form, even if I've only supplied a single object.
I'm not at all opposed to underhanded reflection to solve this problem, but I'm hoping to avoid modifying the source just to send arbitrary data in an HTTP request.
Edit: regarding the requests I'm trying to send, they just look like this:
PUT ... HTTP/1.1
Accept: application/vnd...
Authorization: Basic ...
Content-Type: application/octet-stream
<arbitrary bytes>
Ideally, I'd like to use the same calls to send a different content type:
PUT ... HTTP/1.1
Accept: application/vnd...
Authorization: Basic ...
Content-Type: application/vnd...
<other arbitrary bytes>
There have been some modifications made in the latest version that allow a single file to be used without creating a multipart form request. Here is a gist that shows and example: