Version set not created in Azure APIM when calling through API Managment rest apis

Dibya Ranjan Tripathy 21 Reputation points
2022-03-15T07:32:33.657+00:00

Hi There,

I am trying to automate API proxy creation with a version using Microsoft exposed rest API in Azure APIM. I tried to use both version set and new API creation rest APIs. I got 201 responses from the rest API call but versionset is not reflected in azure APIM in api sections. Could you validate the request payload? Should I call both the rest apis(versionset & api) or only one would enough to create versionset ? I tried all possible ways but api got created with out any version .

To create versionset:

Payload:
{"properties":{"displayName":"sample-api-test1","versioningScheme":"Segment","description":"sample-api-test1","versionQueryName":null}}

Type: Put

URL:
https://management.azure.com/subscriptions/subscriptionid/resourceGroups/RG-APIM-Dev/providers/Microsoft.ApiManagement/service/APIM-Dev/apiVersionSets/sample-api-test1?api-version=2021-08-01

To create a new proxy:

Payload:

{"properties":{"description":"sample-api-test1","authenticationSettings":{"oAuth2":{"authorizationServerId":"oauth-apim-organization","scope":null}},"subscriptionKeyParameterNames":{"header":"Subscription-Key","query":"subscription-key"},"displayName":"sample-api-test1","serviceUrl":"https://dev.jll.com/sample-api-test1/v1","path":"sample-api-test1","protocols":["https"],"apiVersionSet":{"description":"sample-api-test1","id":null,"name":"sample-api-test1","versioningScheme":"Segment"}},"apiVersion":"v1","apiVersionDescription":"sample-api-test1-v1","apiVersionSetId":"/subscriptions/subscriptionid/resourceGroups/JLL-GB-RG-APIM-Dev/providers/Microsoft.ApiManagement/service/JLL-GB-APIM-Dev/apiVersionSets/sample-api-test1","isCurrent":true,"subscriptionRequired":true,"type":"http"}

Type: PUT

URL:
https://management.azure.com/subscriptions/subscriptionid/resourceGroups/RG-APIM-Dev/providers/Microsoft.ApiManagement/service/APIM-Dev/apis/sample-api-test1?api-version=2021-08-01

Azure API Management
Azure API Management
An Azure service that provides a hybrid, multi-cloud management platform for APIs.
1,812 questions
{count} votes

Accepted answer
  1. MayankBargali-MSFT 69,751 Reputation points
    2022-03-22T08:44:13.15+00:00

    @Dibya Ranjan Tripathy Assuming that you are replicating the same behavior that the portal does when you add a new revision set on any of your existing API then you need to call the below APIs. You can also collect the F12/fiddler traces to know what calls are initiated from the Azure portal.

    got 201 responses from the rest API call but versionset is not reflected in azure APIM in api sections.
    The create API version set only creates the version set and doesn't associate with any of the API that is the reason you are not able to see it in the API section on your APIM instance. To see the API and operation you need to execute below API as it is initiated from portal to replicate the same behavior.

    185562-image.png

    https://learn.microsoft.com/en-us/rest/api/apimanagement/current-ga/api-version-set/create-or-update (Only creates the version set and it will not be associated with any API)
    PUT /subscriptions/{subscriptionID}/resourceGroups/{resourcegroupname}/providers/Microsoft.ApiManagement/service/{apiminstance}/apiVersionSets/{versionsetID}?api-version=2021-04-01-preview

    {  
       "id":"/apiVersionSets/{versionsetID}",  
       "properties":{  
          "displayName":"{displayname}",  
          "versioningScheme":"Segment"  
       }  
    }  
    

    https://learn.microsoft.com/en-us/rest/api/apimanagement/current-ga/apis/create-or-update
    PATCH /subscriptions/{subscriptionID}/resourceGroups/{resourcegroupname}/providers/Microsoft.ApiManagement/service/{apiminstance}/apis/{apiID}?api-version=2021-04-01-preview

    {"properties":{"apiVersionSetId":"/apiVersionSets/{versionsetID}"}}  
    

    https://learn.microsoft.com/en-us/rest/api/apimanagement/current-ga/apis/create-or-update
    PUT /subscriptions/{subscriptionID}/resourceGroups/{resourcegroupname}/providers/Microsoft.ApiManagement/service/{apiminstance}/apis/{apiID}-{name};rev={number}?api-version=2021-04-01-preview

    {  
       "properties":{  
          "sourceApiId":"/subscriptions/{subscriptionID}/resourceGroups/{resourcegroupname}/providers/Microsoft.ApiManagement/service/{apiminstance}/apis/{apiID}",  
          "apiVersion":"new",  
          "apiVersionSetId":"/apiVersionSets/{versionsetID}",  
          "apiVersionSet":{  
             "versioningScheme":"Segment",  
             "name":"{anyname}"  
          }  
       }  
    }  
    

    Please let me know if I misunderstood your requirement and please share more details.

    0 comments No comments

0 additional answers

Sort by: Most helpful