Call Azure Form Recognizer API on SharePoint document/image URL in Power Automate

Power Automate (formerly Microsoft Flow) can call Azure Form Recognizer via the connector. However, at the time of this writing, the Form Recognizer v2 connector is not yet available. One of the options is to use the HTTP connection. Refer to my previous post, we can call Form Recognizer API by passing the image URL or binary content. Since Power Automate is a cloud solution, the natural choice is to use the image URL. This should work fine if the URL is accessible to the public or requires no authentication. Unfortunately, the company’s SharePoint URL, most of the time, is not.

The error may be misleading making you think that there is something wrong with URL. I validate the SharePoint URL that the image is displayed properly. When I use a public sample image URL, the HTTP step executes properly. Looking at the error description on the vendor’s site, the InvalidImageURL error code also means that the image is not accessible.

To solve this, we can add another flow step to move the SharePoint file to where it is accessible, or, better, instead of using file URL, we can pass binary content in the Form Recognizer API. In Power Automate, we can use the dataUriToBinary expression to convert data into binary first. Note that we have to change the Content-Type header to the appropriate image type.

dataUriToBinary(triggerBody()['Createfile_FileContent'])

No comments yet.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Powered by WordPress. Designed by WooThemes