Reputation: 85
How can I filter files from HTTP get request in Logic Apps?
My approach is to compose a function something like this
toLower(base64ToString(triggerOutputs()['headers']['x-ms-file-name-encoded']))
but it's not working... I'm completely new one in LogicApps but need it for one project requirement.
Upvotes: 1
Views: 1255
Reputation: 8252
The base64ToString(triggerOutputs()['headers']['x-ms-file-name-encoded'])
helps you to extract the names of the files. While filtering the file of your choice then you can use Condition
connector and save the filtered file to your storage. For example here is my logic app.
After successful run I could able to save the file into one of my blob containers.
If you are trying to filter the files with its file name then use lowercase on both sides for comparison to get it filtered.
I have placed the below expression in the left
toLower(base64ToString(triggerOutputs()['headers']['x-ms-file-name-encoded']))
In the right
toLower('<YOUR_FILE_NAME>')
Note:
I'm using contains to filter the expression in condition
connector so that every file which contains the name or part of the name gets added to my storage account. Also, I'm just using sample content to store in my blob (i.e., blob content) but you can use the one which you require.
This helps to filter CSV files from the sharepoint folder and moves the files which got filtered to the destination folder.
Note: Make sure if you are trying to use file name as filter, like I have already mentioned you can change case of file name into either Lower or upper as this is the main part where sometimes few of the desired folders won't trigger.
Upvotes: 1