0
votes

I am creating a new API in API management by using

PUT https://management.azure.com/subscriptions/d00e3aca-15b5-4f4b-8204-1ded8025c65f/resourceGroups/Default-Web-NorthEurope/providers/Microsoft.ApiManagement/service/idfy-test/apis/demoapi2?api-version=2017-03-01

{ "properties": { "contentFormat": "swagger-link-json", "contentValue": "http://demoapi2.azurewebsites.net/swagger/v1/swagger.json", "path": "demoapi2", } }

PUT https://management.azure.com/subscriptions/d00e3aca-15b5-4f4b-8204-1ded8025c65f/resourceGroups/Default-Web-NorthEurope/providers/Microsoft.ApiManagement/service/idfy-test/products/free/apis/demoapi2?api-version=2017-03-01

(the "free" product is a product which does not require subscriptions) GET http://idfy-test.azure-api.net/demoapi2/api/Values/ works perfect

I then try to make a new revision (to reflect a updated swaggerfile) https://management.azure.com/subscriptions/d00e3aca-15b5-4f4b-8204-1ded8025c65f/resourceGroups/Default-Web-NorthEurope/providers/Microsoft.ApiManagement/service/idfy-test/apis/demoapi2;rev=2?api-version=2017-03-01 { "properties": { "contentFormat": "swagger-link-json", "contentValue": "http://demoapi2.azurewebsites.net/swagger/v1/swagger.json", "path": "demoapi2", } }

The problem now is when calling GET http://idfy-test.azure-api.net/demoapi2;rev=2/api/Values/

I get the following errormessage; { "statusCode": 401, "message": "Access denied due to missing subscription key. Make sure to include subscription key when making requests to an API." }

When trying to connect the revision2 to the same product as revision1, this doesnt seem to work.....

This problem does not occur when I try to create the new revision as a copy from rev=1; My problem is that I want to create a new revision from a updated swagger file, apply policies, and then make the new reivison the active one

Are there any other ways to get the API management to "reload" a updated swaggerfile, test the changes, and then flip revisions?

1

1 Answers

0
votes

{ “statusCode”: 401, “message”: “Access denied due to missing subscription key. Make sure to include subscription key when making requests to an API.” } This error occurs when you miss the subscription key in the header. Let’s jump into the developer portal to see how to get the subscription key. The link to the developer portal is on the upper right corner (or you can remove /admin from the URL) and it looks like: enter image description here

The portal is by default visible to everyone who knows the URL. So it makes sense to customize it to your corporate identity. But let’s focus on the development stuff and let’s test our API. Go to “API” and select your API on the right side: enter image description here

You can now select a method and try it with the “try it” button. It opens a screen which allows you to enter parameters and other stuff. There we can also see the subscription key (Ocp-Apim-Subscription-Key): enter image description here

Press the send button and you will see the API call including the subscription key and also the result of the API call.

Reference: https://codehollow.com/2016/09/introduction-azure-api-management-part-1/.