I want to use a pipline ADF to call an API REST which used an sql table and extracts one or more files.
API should return 3 files if the table contains 3 different regions, for this reason I used the following activities:
A lokupctivity : it’s a query ( distinct on the column Regions) to get all the regions present in my table. ———> the result :
"value": [{"RegionCode": "10" },{"RegionCode": "60"},{"RegionCode": "50"}],`
EachActivity(Check_Region_In_Table) :to call my API for each Region enter image description here
After that I call my API that use a token, id, secret but in the body i can’t get one region enter image description here
This is my body
@json(concat('{"sourceTable": "table","query": "select * from table where RegionCode="',activity('Check_Region_In_Table').output.value[0],'","outputFileType" : "csv","optionList":"nullValue=null|delimiter=t|header=false","outputFolder": "activity('Check_Region_In_Table').output.value[0]",file-{YYYY}-{MM}-{dd}-{HH}-{mm}-{ss}.txt"}'))
But i get an error that is not valid
The result should return 3 files(i have 3 Regions) with 3 different name R10_file2022-15-04-15-48-30.txt
Advertisement
Answer
As wBob mentioned in comments section, when you are referring lookup output value inside ForEach
activity, use item().columnname {ex: @item().RegionCode}.
- Pass the output of lookup activity in the ForEach activity settings.
In your ForEach, use the expression with
item().RegionCode
to refer the lookup column value.@concat('{"sourceTable": "table","query": "select * from table where RegionCode="', item().RegionCode,'","outputFileType" : "csv","optionList":"nullValue=null|delimiter=t|header=false","outputFolder":', item().RegionCode,'file-{YYYY}-{MM}-{dd}-{HH}-{mm}-{ss}.txt"}')