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>
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…