BUG in Azure Data Factory -> Set Variable -> Add dynamic content -> content contains a dash in its name

Peter 51 Reputation points
2021-01-08T09:52:47.987+00:00

Hi,

I am attempting to set a variable by referring to an element inside a json array.

The array element has dashes (-) in its name.

This fails:
@array([activity('Get Item Count').output.ADFWebActivityResponseHeaders.X-Total-Count])

This succeeds:
@array([activity('Get Item Count').output.ADFWebActivityResponseHeaders.ServerName])

Does anybody know how to escape the dashes?

I have tried all sorts of combinations using \ / , ' " to no avail.

The error I get is:

{
"code":"BadRequest",
"message":"ErrorCode=InvalidTemplate,
ErrorMessage=Unable to parse expression 'array([activity('Get Item Count').output.ADFWebActivityResponseHeaders.X-Total-Count])'",
"target":"XXXXX",
"details":null,
"error":null
}

Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
9,341 questions
{count} votes

Accepted answer
  1. Daniel 86 Reputation points
    2021-01-12T15:29:33.21+00:00

    Hi @Peter

    I also hit this issue today.
    Have you tried this solution?
    https://stackoverflow.com/questions/61937105/data-factory-retrieve-value-from-field-with-dash-from-json-file

    So in your case it would be:
    @array([activity('Get Item Count').output.ADFWebActivityResponseHeaders['X-Total-Count']])

    2 people found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. TerriblyVexed 51 Reputation points
    2021-10-25T15:02:14.523+00:00

    I ran into this today also. It is happening in a ForEach activity. I'm trying to get the Content-Location returned from a Web Activity Response Header.
    Output
    {
    "Response": "",
    "ADFWebActivityResponseHeaders": {
    "Request-Context": "appId=cid-v1:.....",
    "X-Request-ID": "66832d597403aa4e8c521f1bc837fadb",
    "x-ms-session-token": "0:-1#638764",
    "x-ms-request-charge": "19.85",
    "Strict-Transport-Security": "max-age=31536000; includeSubDomains",
    "X-Content-Type-Options": "nosniff",
    "Date": "Mon, 25 Oct 2021 14:22:29 GMT",
    "Server": "Kestrel",
    "Content-Length": "0",
    "Content-Location": " https://site.azurehealthcareapis.com/\_operations/export/416cddbd-071e-48e5-9952-00774d30e5bd "
    },
    "effectiveIntegrationRuntime": "IntegrationRuntime (North Central US)",
    "executionDuration": 0,

    The provided workaround is NOT working for me. In my ForEach Items I have:
    @array([activity('StartExportTask').output.ADFWebActivityResponseHeaders.['Content-Location']])

    and I get:
    Error
    Notifications
    {"code":"BadRequest","message":null,"target":"pipeline//runid/1f5588ce-b4bf-4841-bf66-865594371c97","details":null,"error":null}

    also I try:

    @activity('StartExportTask').output.ADFWebActivityResponseHeaders.['Content-Location']

    With the same results. Please help.