Path parameter in API suffix Azure API management

365 views Asked by At

Is it possible to create multiple APIs in Azure APIM that contain path parameters. I want to create multiple apis like this:

Users https://{MyAPI}.azure-api.net/organisations/{orgId}/users

EntityTypes https://{MyAPI}.azure-api.net/organisations/{orgId}/entitytypes

Workflows https://{MyAPI}.azure-api.net/organisations/{orgId}/workflows

I need to give different products access to different Apis. eg. One product only has access to Users and UserTypes and the other has access to everything.

Is this possible in Azure APIM?

I tried adding the path parameter in the API URL suffix field but keep getting URL invalid error. I also have not seen any of this in the documentation. (I might be going with this the wrong way)

Image with error

EDIT: Updated question layout.

1

There are 1 answers

4
Ikhtesam Afrin On BEST ANSWER

You can add the below URLs in Azure APIM in the following way-

Users https://{MyAPI}.azure-api.net/organisations/{orgId}/users

EntityTypes https://{MyAPI}.azure-api.net/organisations/{orgId}/entitytypes

Workflows https://{MyAPI}.azure-api.net/organisations/{orgId}/workflows

Initially, I created an API

enter image description here

Then added Users, EntityTypes and Workflows as operations in it.

enter image description here

enter image description here

enter image description here

You can check the Json file wherein orgid is added as a path parameter.

{
    "openapi": "3.0.1",
    "info": {
        "title": "Test API",
        "description": "",
        "version": "1.0"
    },
    "servers": [{
        "url": "https://*****.azure-api.net/organisations"
    }],
    "paths": {
        "/{orgId}/users": {
            "get": {
                "summary": "Users",
                "operationId": "users",
                "parameters": [{
                    "name": "orgId",
                    "in": "path",
                    "required": true,
                    "schema": {
                        "type": ""
                    }
                }],
                "responses": {
                    "200": {
                        "description": null
                    }
                }
            }
        },
        "/{orgId}/entitytypes": {
            "get": {
                "summary": "EntityTypes",
                "operationId": "entitytypes",
                "parameters": [{
                    "name": "orgId",
                    "in": "path",
                    "required": true,
                    "schema": {
                        "type": ""
                    }
                }],
                "responses": {
                    "200": {
                        "description": null
                    }
                }
            }
        },
        "/{orgId}/workflows": {
            "get": {
                "summary": "Workflows",
                "operationId": "workflows",
                "parameters": [{
                    "name": "orgId",
                    "in": "path",
                    "required": true,
                    "schema": {
                        "type": ""
                    }
                }],
                "responses": {
                    "200": {
                        "description": null
                    }
                }
            }
        }
    },
    "components": {
        "securitySchemes": {
            "apiKeyHeader": {
                "type": "apiKey",
                "name": "Ocp-Apim-Subscription-Key",
                "in": "header"
            },
            "apiKeyQuery": {
                "type": "apiKey",
                "name": "subscription-key",
                "in": "query"
            }
        }
    },
    "security": [{
        "apiKeyHeader": []
    }, {
        "apiKeyQuery": []
    }]
}

In this way, you can add the path parameters.