Open ronando82 opened 4 months ago
RestSharp doesn't encode query parameters when it is told not to. For example, this simple test passes:
[Fact]
public void Should_not_encode_pipe() {
var client = new RestClient("http://example.com");
var request = new RestRequest("resource");
request.AddQueryParameter("ids", "in:001|116", false);
var actual = client.BuildUri(request);
var expected = new Uri("http://example.com/resource?ids=in:001|116");
actual.Should().Be(expected);
}
However, what I found now is that the Uri
object encodes the pipe character. So, the actual URI values in both expected
and actual
vars in the test contain the same string with encoded pipe char, where the original URL string property for both of them contain non-encoded values.
I fixe in my PR but for .NET < 6 the code uses an obsolete Uri
ctor. It works, just hoping they won't remove it.
Sorry, closed prematurely. It still has issues with how some characters are encoded, it's different per framework. Will look at it again soon.
Describe the bug i use AddQueryParameter with false attribute to prevent encoding my string but it doesn't work.
Example : .AddQueryParameter("ids", "in:001|116", false);
To Reproduce
the transmitted parameter is:
ids=in:001**%7C**116
For example it's work with a slash
/
instead a pipe character|
the transmitted parameter is:
ids=in:001/C116
Expected behavior
i would expect not encoding the pipe character
Desktop (please complete the following information):