azureazure-api-managementapim

Curly brace literals in an Azure APIM variable expression


We are attempting to create a Workday query (WQL) in an Azure APIM policy. The query requires curly braces to be in the query string. No matter what we have tried, APIM interprets the curly braces as containing a variable when all we want it literal curly braces. Here is what we have right now for setting the variable:

<set-variable name="wqlQuery" value="@{
        return "PARAMETERS prompt_Date1 = '" + (string)context.Variables["inputDateString"] + "' SELECT worker, cf_CFESIINT5000_F {workdayID, clockEventType, clockEventTime_NoTimeZone} AS clockEvent FROM workersForHCMReporting (dataSourceFilter = allActiveWorkers) WHERE cf_CFESIINT5000_F is not empty";
}" />

The issue is that the {workdayID, clockEventType, clockEventTime_NoTimeZone} part is interpreted as variables. We get the error "Variable workdayID, clockEventType, clockEventTime_NoTimeZone has no value." The way to insert a variable into a string in an APIM policy expression is to use double curly braces, e.g. {{my_variable}} so I am not sure why these are being interpreted as variables. Despite that, I have tried double, triple and quadruple quotes as well as escaping with \{ and \}. I have also tried URL encoded values, i.e. %7B and %7D (Edit - it looks like the URL encoding actually works).

The variable is used to rewrite the URI, like so:

<rewrite-uri template="@{
        return "/wql/v1/{{workday-api-tenant}}/data?query=" + (string)context.Variables["wqlQuery"];
    }" />

However, I have tried to use the query directly in the rewrite-uri tag rather than setting a variable and have had the same result.

The WQL query works in Postman, so this is definitely just an issue with APIM interpreting that part as variables.

Can someone tell me what I need to do to make those curly braces interpreted as literals?


Solution

  • URL encoded values, i.e. %7B and %7D fixed the problem