ServiceStack and Azure API Management

Hi all,

I am working on a POC utilizing ServiceStack and Azure API Management. I have a very simple API created in Service Stack and registered in the Azure API Management portal. I am using the service model library as usual and the JSON service client to make the calls. But instead of pointing directly at my ServiceStack api, I am pointing at the Azure API Gateway instead.

When I make the call, I got a response that the resource could not be found, because it stead of going to https://url/api/create it went to https://url/api/json/reply/create. Is there a way to force the client to use the defined routes such as [Route("/create", “POST”)] other than using the client send function override, where you defined the https method, url and object.

Basically, I would like to call it like this …

client.send(request);

instead of

client.sent(“POST”, “/create”, request);

It’s not clear which Service Client you’re referring to, but only the C#/.NET Service Clients uses the custom routes defined in [Route] definitions on the Request DTO, all other languages use the pre-defined routes. To override you’d need to specify the custom route as you’re doing in your example.

I am using the JSONServiceClient.

I have the route defined in the service model as [Route("/create",“POST”)].

The call is not using the route defined, but the pre-defined routes instead.

That is the issue.

What language?

Note all languages name their JSON Service Client JsonServiceClient.

I am using C#.

JSONServiceClient

You mean JsonServiceClient.

For C# it should automatically use the best matching route definition it can find, please provide the full Request DTO class definition the client is using and the exact client source code that makes the reqeust so we can check to see what the best matching route should be and be able to repro the call where it’s falling back to use pre-defined route.

The likely issue is that you’re using client.Send() instead of client.Post() where one of the differences is that Send() uses the pre-defined route unless the Request DTO is annotated with IPost in which case it behaves like:

client.Post(new MyRequest());

So you need to either use the client.Post() API or annotate your Request DTO with the IPost interface marker.

Using Post() instead of Send() worked. However, adding the IPost to the Request DTO did not change the route.

Thanks for the help.