A few years ago I wrote the blog post Import Windows Autopilot devices with Logic Apps. The Logic Apps flow that I described imports a csv file containing the Windows Autopilot information including the hardware hash.
I noticed recently the SharePoint trigger When a file is created in a folder that I use in this flow is marked as deprecated. This means I need to replace the trigger with another one. But as that gave me some issues, I’m writing this blog post, so you don`t waste time in replacing the deprecated trigger.
My original flow with the deprecated trigger looks like below. Important in this screenshot, is the trigger and I use the File Content in the CSV action, which is a Compose action.
When we have a look at the Runs history we can see the actual data processed by the first part of the flow.
Here we see in the trigger and the compose action, we can just read the information from the imported CSV file.
We can replace the trigger with the When a file is created (properties only) trigger. It does the same job as the deprecated trigger, with the big difference that it doesn`t retrieve any file content of the file.
That`s not an issue as we have a SharePoint action Get file content.
The only thing we don`t need to forget is to add the File content of the Get file content action to the Inputs field of the compose action, and we’re done.
That was at least what I hoped for. But my following actions that further process the data of the csv file failed.
When I had a look at the Runs history, I noticed the data isn’t readable anymore, it seems the data is encoded.
Well, there we have the issue 🙂
I have tried to decode the data using an expression including base64tostring, base64, base64ToString etc etc. None of these did work for my flow.
I noticed the encoding of the csv files which we get when exporting the Windows Autopilot information is UTF-16. When I manually changed the encoding of a file to UTF-8, I could process the file without any issues. I scratched my head again (a couple of times) and started to investigate if I could change the encoding of the file using the file, but also without any luck.
I even opened a support case at Microsoft, which was open for a long time, and tried all sorts of workarounds together with the support engineer. And finally, we come to the solution. And it is so simple if you know the solution. We need to use an Expression with string:
We can create this expression by typing in string, followed by two brackets.
With the cursor between the brackets switch to the Dynamic content tab and select File content.
And we have our expression added to the compose action.
When we now run the flow and have a look at the Runs history, we see we can read the data again.
It`s so easy sometimes 🙂
I hope this saved you some time in replacing the When a file is created in a folder (deprecated) trigger.