Cannot create API on Azure API Management which contains {} in the URL Path using bicep

Nagul M Shaik 20 Reputation points
2025-05-28T20:18:17.3533333+00:00

Cannot create API on Azure API Management which contains {} in the URL Path using bicep

resource apiOperation 'Microsoft.ApiManagement/service/apis/operations@2022-08-01' = {

name: '${apimName}/${apiName}/${operationName}'

properties: {

displayName: operationName

method: method

urlTemplate: urlTemplate

description: operationDescription

request: {

  description: '${method} request for ${operationName}'

  headers: headers

}

}

}

urlTemplate value should be {purchaseorder} , but when I give it in bicep the validation failing, cannot create API, even tried with different combinations including double quotes, single quotes around the brackets or within it.

is there way we can make sure the bicep passes {} as a string ?

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

Answer accepted by question author
  1. RChotu 3,210 Reputation points Microsoft External Staff Moderator
    2025-05-29T10:25:11.97+00:00

    Hi @Nagul M Shaik ,

    Using flower braces directly is not supported but to send a value during the execution time and to use {} inside the urlTemplate, one has to also define templateParameters as below:

    param rithapimNme string = 'testapirith'
    param apiName string = 'sample-api'
    param riopname string = 'get-operation'
    resource api 'Microsoft.ApiManagement/service/apis@2022-08-01' = {
      name: '${rithapimNme}/${apiName}'
      properties: {
        displayName: 'Sample API'
        path: apiName
        protocols: [ 'https' ]
        serviceUrl: 'https://httpbin.org/anything' 
      }
    }
    resource apiOperation 'Microsoft.ApiManagement/service/apis/operations@2022-08-01' = {
      name: '${rithapimNme}/${apiName}/${riopname}'
      dependsOn: [ api ]
      properties: {
        displayName: 'Get the Order'
        method: 'GET'
        urlTemplate: '{purchaseorder}'  
        templateParameters: [
          {
            name: 'purchaseorder'
            type: 'string'
            required: true
            description: 'Purchase order ID'
          }
        ]
        request: {
          description: 'Hey Rithwik, Test request for Operation'
          queryParameters: []
          headers: []
        }
        responses: [
          {
            statusCode: 200
            description: 'Succeeded'
            representations: []
          }
        ]
      }
    }
    
    

    Output:

    image

    If Value given it changes as below:

    enter image description here

    enter image description here


    If this answer was helpful, please click "Accept the answer" and mark Yes, as this can help other community members.

    enter image description here

    If you have any other questions or are still experiencing issues, feel free to ask in the "comments" section, and I'd be happy to help.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.