Non-utf8 payloads in Logic Apps

In enterprise integration it is quite common to deal with legacy applications that communicates by creating and consuming files. Logic Apps are well positioned to handle these type of integrations as  they can handle most file transferring protocols such as ftp, file, sftp etc.

However, a drawback is that Logic Apps handles all text in UTF-8 format. If you are fetching files which are not encoded in UTF-8 but another encoding you might run in to some trouble.

If your requirement is to transfer data, without actually manipulating it (i.e. a simple file transfer) you can easily do so in a Logic app, even though the file might have another encoding than UTF-8. The actions supporting this are for example: 

The first thing you will want to do is to disable the “Infer Content Encoding” in the action that is fetching the data. This will stop the Logic App from trying to “guess” the content type and the encoding of it. This is accessible under the advanced options in the action fetching the data.

This means that the Logic App will not try to guess the encoding of the data it fetches from the source, but rather treat it as an octet stream. If you are just picking up a file and dropping it somewhere else you are more or less done now, you can let the information pass through your logic app and it will not get corrupted.

Referring to the octet stream.

When choosing not to infer the content type you will get content looking like this:

{
	"$content-type": "application/octet-stream",
	"$content": "UnVlIEJlYXUtU+hqb3VyDQrF5vjF5PY="
}

To refer to the content of the file use the following syntax:

"@body('Get_blob_content')['$content']"

Hope this helps you to get on with your Logic App integrations!

Happy coding!