2
votes

Having a weird issue with API development, just wondering if anyone knows the solution/what I have done wrong?

I have an API http://company/api/products which is an azure function that works correctly, and is set up as a single api in api management. Using azure api management I created a new version which has the version identifier of v2 so the link becomes http://company/api/v2/products

But I find this link just points to the original API still, and not the new version(Route c# code below). I find that if I change the frontend URL of my products api in the new version to /v2/products rather than /products, it does work, but that means that my URL is now http://company/api/v2/v2/products, which isn't what I wanted.

I COULD create a new version with no identifier (maybe?) and set the path of each url manually, but expected a new version to create the new route as well, and would prefer that for maintenance reasons

in my c# code/function I have new method with a httpTrigger that looks like this; locally it works 100% correctly (or on /v2/v2/products it works)

[HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "v2/products")] HttpRequest request,

It's like the version identifier isn't used in the route at all, is there something I'm missing to pick it up?

1

1 Answers

1
votes

In the API Management Publisher portal, you can update the Backend API URL for the new version as http://{backend api base url}/v2

This way any request that is going to the backend api will be routed correctly.