I'm using ServiceStack for a while now and I'm very happy with the functionality it provides. Already implemented serveral services with it and it works like a charm.
Recently however I've faced a problem with calling other service with a sophisticated URL that has to be encoded properly.
The code is the following:
The Request:
[Route("/instruments/{Names}")]
internal class Request
{
public List<string> Names { get; set; }
}
And the method call:
var request = new Request { Names = list };
var c = new JsonServiceClient("http://host:12345/");
Response[] response;
try
{
response = c.Get<Response[]>(request);
}
catch (WebServiceException ex)
{
HandleWebException(ex, list);
yield break;
}
And now the problem is that sometimes the name can contain a special characters like space or /. I'd like to have those propery encoded. For instance I'd like to be able to call the remote service with the following parameters: "D\S N" with is supposed to be encoded to "D%5CS%20N". So the called URL should look something like this:
http://host:12345/instruments/D%5CS%20N
And now the problem is that JsonServiceClient does the bad encoding here. What I call is actually:
http://host:12345/instruments/D/S%20N
With is obviously wrong. Any help how to sort this out is appeciated.