What should be the structure if I want to use concat and encodeURI in the same JSON for Azure DevOps pipeline

Viewed 42

I have a code in my logic app that gets a list of warehouses from an API URL. In it, I am trying to define a parameter that picks my URL for the azure DevOps pipeline when deploying my logic app, but when I run the pipeline I get the error

Deployment template validation failed: 'The template resource 'MyLogicApp' at line '1' and column '1465' is not valid: Unable to parse language expression 'concat('/v2/datasets/@{encodeURIComponent(encodeURIComponent(''https://',parameters('myApiUrl'),'.com''))}/tables/@{encodeURIComponent(encodeURIComponent('msdyn_warehouses'))}/items')': expected token 'RightParenthesis' and actual 'Identifier'.. Please see https://aka.ms/arm-template-expressions for usage details.'.

This is what my json looks like

"
    [
        concat
        (
            '
                /v2/datasets/@
                {
                    encodeURIComponent
                    (
                        encodeURIComponent
                        (
                            '
                                '
                                    https://
                                ',
                                parameters
                                (
                                    '
                                        myApiUrl
                                    '
                                ),
                                '
                                .com
                                '
                            '
                        )
                    )
                }/tables/@
                {
                    encodeURIComponent
                    (
                    encodeURIComponent
                            (
                                '
                                    msdyn_warehouses
                                '
                            )
                    )
                }/items
            '
        )
    ]
"

If I use it without concat, it works

"path": "/v2/datasets/@{encodeURIComponent(encodeURIComponent('https://bla.bla3.com'))}/tables/@{encodeURIComponent(encodeURIComponent('msdyn_warehouses'))}/items"

Is there a specific way to format concat and encodeURI together that I am missing?

1 Answers

After checking thoroughly, you are receiving the above-mentioned error as because of the incomplete template (i.e., it misses a right parenthesis).

the uri from the parameter within the encoding statement

In that case you need to include concat() inside the encodeURIComponent and below is how you need to frame.

/v2/datasets/@{encodeUriComponent(encodeUriComponent(concat('https://',parameters('myApiUrl'),'.com')))}/tables/@{encodeURIComponent(encodeURIComponent('msdyn_warehouses'))}/items
Related