I'm in the process of creating an Azure Logic App to work with Abbyy's OCR REST API.
I use the Create SAS URI by path
action which returns Web URL
. Web URL
returns the FQDN, incuding the SAS token, to my blob.
Web URL
is passed to an Http
action as a query parameter. In code view, the relevant part of the JSON looks like:
"method": "GET",
"uri": "https://cloud.ocrsdk.com/processRemoteImage?source=@{body('Create_SAS_Uri_by_path')?['WebUrl']}&language=English&exportformat=pdfSearchable&description=blah&imageSource=scanner"
The uri resolves thus:
https://cloud.ocrsdk.com/processRemoteImage?source=https://mysaaccount.blob.core.windows.net/inbox/180730110047_0001.pdf?sv=2017-04-17&sr=b&sig=2IGMt1qDZthaBSyvD3WJ6T1zc36Wr%2FNoiB4Wki5Lf28%3D&se=2018-08-16T11%3A16%3A48Z&sp=r&language=English&exportformat=pdfSearchable&description=blah&imageSource=scanner"
This results in the error (450):
<?xml version="1.0" encoding="utf-8"?><error><message language="english">Invalid parameter: sr</message></error>
Which is basically picking up sr=
query parameter from the SAS token and of course, the API doesn't have an sr
argument, and even if it did, its value would be wrong.
I did find this question and I attempted "percent-escape" the ampersands (&) by adjusting my code to use the replace
function, thus:
"method": "GET",
"uri": "https://cloud.ocrsdk.com/processRemoteImage?source=@{replace(body('Create_SAS_Uri_by_path')?['WebUrl'],'%26','%2526' )}&language=English&exportformat=pdfSearchable&description=blah&imageSource=scanner"
However, this has no effect. I.e the resulting URI is the same as above. Interestingly, it appears the SAS token itself has made use of "percent-escape".
If anyone has any suggestion on how to resolve or work around this problem, I'd be most greatful if you would share your thoughts.
Does anyone know if the LogicApp actions are opensource and if so what the GitHub link is. I can then raise an issue.