Do not encode parameters in RestSharp

I am using RestSharp to access the RubyOnRails API. As you know, RoR likes when parameter names are in form model_name[property]. RestSharp, on the other hand, doesn't like it.

Fiddler says that I am sending this to the server:

user%5Bemail%5D=user%40email.com&user%5Bpassword%5D=test

It seems that R # encodes both parameters and values ​​when sending data (unlike Curl, which looks like it is selectively encoded). While this is fine, I think in this particular case it returns API 401 because it does not understand the parameters.

Is it possible to request R # not to encode request parameters?

Thank!

Edit

Well, in R # sources, I found the RestClient.EncodeParameters method, so it looks like the parameter name is always encoded. I think I will have to fork it :(

+4
3

RestSharp , ( , ), , , .

+3

, , , . ( ) . uri , .

var uri = string.Concat("/path/to/your/api", "?paramThatShouldNotBeEncoded=", DateTime.Now.Date.AddDays(1).ToString("O"));
var restRequest = new RestRequest(uri, Method.GET);
+4

... , , restsharp , . , api, % 7 , RestSharper . api RestSharp, , , !

0
source

Source: https://habr.com/ru/post/1529426/


All Articles