I am using RestSharp to access a RubyOnRails API.
As you might know, RoR likes when the parameters names are in the form model_name[property]
. RestSharp, on the
Update: probably doesn't work in most cases from comments.
I found an interesting solution... Just decode the parameters you want to pass in and restsharp will encode back to what it should be. For example, I have an api key that uses %7 in it and RestSharper further encodes it. I decoded the api key and passed that into RestSharp and it seems to work!
In the RestSharp sources I found out that the parameters are always encoded (both the name and the value), so I guess that I will have to fork it if I want to add an additional parameter.
Since RestSharp version 106.4.0 you can just use ParameterType.QueryStringWithoutEncode
in request.AddParameter()
function:
request.AddParameter("user_id", @"45454545%6565%65", ParameterType.QueryStringWithoutEncode);
I know this has already been answered, but I wanted to add this answer since it worked for me. There is an (albeit hacky) solution to this. Build your own uri for parameters that should not be encoded.
var uri = string.Concat("/path/to/your/api", "?paramThatShouldNotBeEncoded=", DateTime.Now.Date.AddDays(1).ToString("O"));
var restRequest = new RestRequest(uri, Method.GET);
See this PR from the project site: https://github.com/restsharp/RestSharp/pull/1157
However, as far as I can tell, it's not yet in a release on NuGet.