简体   繁体   中英

azure data factory - convert single value output from query into json

In azure data factory, I am getting a single record back from a database. I need to take one column from this and pass it to a web call body.

The body takes data in this format:

["cdd-lm-54"]

I have tried multiple expressions but none of them work. appreciate any advice on how to perform this.

The data returned from the database looks like this:

 "value": [
        {
            "RowNumber": 1,
            "Tag": "cdd-lm-54",
            "Val1": "val 1",
            "Val2": "val b",
            "LastSyncDateTime": "2022-07-26T13:14:28Z",
            "LastTimeModified": "2021-07-28T10:33:47.7Z"
        }
    ]

The below expressions are the closest i have gotten, they output the data as i expect it to be but the web call still rejects it:

@concat('[','"',pipeline().parameters.DeviceRecord[0]['Tag'], '"',']') 在此处输入图像描述

@concat('[','''',pipeline().parameters.DeviceRecord[0]['Tag'], '''',']') 在此处输入图像描述

Odd thing is if i paste the exact value from ADF into postman, it works.

is adf doing something odd to the body?

Odd thing is if I paste the exact value from ADF into postman, it works.

The reason behind this is that the value that you take from the value and give it as ["cdd-lm-54"] , it indicates that the body accepts an array containing required string.

  • Using @concat() to build ["cdd-lm-54"] will return a just a string, which is not the required data that the body accepts.
  • Instead use the following dynamic content
@array(pipeline().parameters.DeviceRecord[0]['Tag'])
  • The above returns an array containing the required value.在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM