How can I send raw bytes POST request in RestSharp?

52 Views Asked by At

I tired sending post request in RestSharp. For some reasons, I must send a byte array.

But I tried using one way, and it didn't work.

restRequest.AddParameter(string.Empty, array, ParameterType.RequestBody);

In fact, it just send a string:

System.Byte[]

It seems that RestSharp call the ToString() method.

How can I send a byte array?

1

There are 1 best solutions below

0
Bill Tutt On

You can see the extension method that will help you with this here: RestRequestExtensions AddBody method. If request.RequestFormat == DataFormat.Binary without a Content-Type then that method should work. If the obj parameter has the type byte[], it should do what you desire.