I’m using a JsonServiceClient configured as following:
new JsonServiceClient(endPoint)
{
OnAuthenticationRequired = OnAuthenticationRequired,
TypedUrlResolver = TypedUrlResolver,
UrlResolver = UrlResolver
};
Everything works fine if I remove the TypedUrlResolver. The delegate is built as follow:
private static string TypedUrlResolver(IServiceClientMeta client, string httpmethod, object requestdto)
{
string url = requestdto.ToUrl(httpmethod);
var matches = Regex.Match(url, @"(.*)\??(.*)?");
string path = matches.Groups[1].Value;
string query = matches.Groups[2].Value;
var builder = new UriBuilder(client.BaseUri)
{
Path = string.Format("api{0}", path),
Query = query
};
return builder.ToString();
}
The delegate crashes on ToUrl(method) with the following exception:
System.InvalidOperationException: There are no rest routes mapped for 'ServiceStack.Authenticate' type. (Note: The automatic route selection only works with [Route] attributes on the request DTO and not with routes registered in the IAppHost!)
The request is the Authenticate request that, in fact, does not have a [Route] attribute and gets resolved fine without the TypedUrlResolver. How can I solve the URL for those kind of DTO or just skip entirely and let the JsonServiceClient resolve the URL as if the TypedUrlResolver was missing?
Thanks.