I'm using Forms Recognizer and have trained a model to extract keys from PDF attachments. This works fine manually and I can extract the data from the JSON. I used this to set this up:
https://docs.microsoft.com/en-us/azure/cognitive-services/form-recognizer/quickstarts/python-labeled...
The included Forms Recognizer actions in flow appear to not be updated to the latest versions and fail to find the model id, as seen here. Using the HTTP calls in that post I am able to run an analysis using my trained model but I can't seem to find exactly how to send file attachments either from a Sharepoint List or an Email attachment. Here is my HTTP POST:
This returns a succeeded but all of the trained fields are 'null'. If I try to take the actual contents of my get attachment operation I get a failed return of "The input data is not a valid image or password protected." I'm not sure if I'm passing the file correctly to the HTTP POST call. The current iteration of my flow does a dataURItoBinary on a base64 version of the file. The form recognizer see this as a PDF file but doesn't parse the data correctly so I think I may have destroyed the contents of the file at that point with conversions, but unable to find something valid. Is there a way to convert the pdf file to binary and then send it in the body of the POST or am I off base in trying to convert the file. Here is the full flow:
Thanks for any help.
Solved! Go to Solution.
Hello.
I have a custom connector that operates on the PDFs.
Generally, try creating expressions with the file content. Try every one of them. If flow stops working again try another one. There is plenty of issues with that.
String('Filecontent')
base64('Filecontent')
decodeBase64('Filecontent')
base64tostring('Filecontent')
base64tobinary('Filecontent')
One of them will work however It can stop working without any change.
I would recommend to create custom connector for that.
If my post was helpful don't forget about kudo me and mark my post as solution.
Hey Mike, I followed you here from the other post.
In the other post I noticed in your print that you were sending the file in a slighlty different way than I did. I remember I had the same problem you're having now when I was seting up my flow.
The way I did it was to send "Attachements Content" on the Body. I might have changed it directly in code view, like this:
(for some reason I cant upload pictures to this answer, so i'll copy/paste the code view for the HTTP Post)
{
"inputs": {
"method": "POST",
"uri": "https://<....>.cognitiveservices.azure.com/formrecognizer/v2.0-preview/custom/models/dbb5cbf3-15c3-4c57-86d9-574c9d665686/analyze",
"headers": {
"Content-Length": "",
"Content-Type": "application/pdf",
"Host": "<....>.cognitiveservices.azure.com",
"Ocp-Apim-Subscription-Key": "<....>"
},
"body": "@base64ToBinary(string(items('For_each')?['ContentBytes']))"
},
"trackedProperties": {
"Operation-Location": ""
}
}
The important part is: "body": "@base64ToBinary(string(items('For_each')?['ContentBytes']))"
Can you give it a try?
Edit: Coudn't upload images because wasn't logged in
Hello.
I have a custom connector that operates on the PDFs.
Generally, try creating expressions with the file content. Try every one of them. If flow stops working again try another one. There is plenty of issues with that.
String('Filecontent')
base64('Filecontent')
decodeBase64('Filecontent')
base64tostring('Filecontent')
base64tobinary('Filecontent')
One of them will work however It can stop working without any change.
I would recommend to create custom connector for that.
If my post was helpful don't forget about kudo me and mark my post as solution.
@Anonymous Thanks for the help.. you helped me a ton. I couldn't ever get Flow to show the "Attachment Content" like in your flow. What ended up working, thanks @Anonymous, was using base64toBinary on the file content directly. Here is the HTTP call that worked:
Code view:
-Now to start parsing data. Using this to automate some invoice processing to save my accounting team some manual headaches..
Thanks!
@Anonymous -Do you have a suggestion on where to start on creating a custom connector? I found some microsoft documentation on creating one using azure logic apps, no sure if I'm barking up the wrong tree there.
I think it's a new topic. Make new post and mark me there. I will try to help.
Learn to digitize and optimize business processes and connect all your applications to share data in real time.
Did you know that you could restore a deleted flow? Check out this helpful article.
Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.
User | Count |
---|---|
28 | |
28 | |
26 | |
25 | |
23 |
User | Count |
---|---|
63 | |
51 | |
44 | |
31 | |
30 |