I am trying to add an attachment to the Power Automate Approval using append array. However, it fails on the content bytes.
Has anyone successfully attached an item from sharepoint to the power automate approval connector?
Solved! Go to Solution.
This is what I see in the peek code for the side of my if statement which is where an excel file would end up.
Hi all,
So I found the issue. It was in the content expression. I found the fix in another blog entry that I cannot locate again currently, if I do I'll post a link to it. Basically the issue is as seen below:
Original expression I tried as noted in this thread: body('Get_attachment_content')['$content']
Updated working expression: body('Get_attachment_content')?['$content']
For me it appears the missing ? corrected the issue. I can now attach Excel files to an approval flow using the updated expression.
I read many posts about this issue but still not solved.
I can read approval email with attachments, however the attachments appear as a single file, which cannot be recognized, could you please help?
For the ContentBytes, I tried several expressions, still not work.
This YouTube video (https://youtu.be/i01vMGr-qdA) explains the steps from A to Z pretty well.
Please note the video describes appending attachments via 'normal' Send an Email option so it uses "ContentBytes" key there. While "ContentBytes" somehow doesn't work for Approvals email so you need to replace it with "Content" as @yashag2255 and @bschult2 mentioned in their previous threads.
If you get it right, it should look something like this via Peek Code view:
{
"inputs": {
"name": "arrAttachments",
"value": {
"Name": "@items('Apply_to_each')?['DisplayName']",
"Content": "@body('Get_attachment_content')?['$content']"
}
}
}
It works for me. Hope it works for you.
Hi Philip
Thank you for your reply.
Firstly, I did flow the video and create the flow as accordingly. The attachment did not upload into the email and also no attachment in the SharePoint List, the flow is successful run.
So I don't know what happened. is it the variable name? MS Form is name as Supporting Documents for attachment, does it affect the flow?
Flow works,but no attachment in list and email.
or can I use Parallel Branch ??
😥
or will this work??
am at a lost.. how to make the attachment (pdf) send with the approval email and update into the list.. what did I do wrong :(... Thanks.
This is driving me crazy..and I need to use it asap.. I had tried for months on it.. if someone has success with such flow, please help. 😞
Why so hard to get it up .. help..
Thank you
Hi @bbsin
You can check the below post on how to add attachments to approvals: https://www.bythedevs.com/post/how-to-add-multiple-attachments-on-approval-actions-in-power-automate
And then in the attachments get the attachments from the form as shown in the previous responses.
Hope this Helps!
If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!
Hi yashag3355
does it mean that I change the megabyte content to content?
Sorry I am a developer so I don't really understand. Tks
Hi @bbsin
Correct. Replace ContentBytes with content for the approvals.
Hope this Helps!
If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!
Hi yashag2255
I don't know why I change and the flow is working successful but still no attachment in list and email 😭
It generates only mail with attachment & for every attachment it generates separate mail.
No approval asked.
There are two different variables in the Attachment array, one for emails and a second for Approvals.
for email
{
"name":@{items('Apply_to_each')?['DisplayName']},
"ContentBytes":@{body('Get_attachment_content')['$content']}
}
For Approval actions
{
"name":@{items('Apply_to_each')?['DisplayName']},
"content":@{body('Get_attachment_content')['$content']}
}
used in Email
Used in Approval
@bbsin were you able to get the Power app Approval workflow to work correctly with attachments? look at my post with the screen shots. It took me three days to find that there are two different variables inside the Attachment array.
I had this but its not working, not collecting attachments.
Same JSON tried for email, getting no of emails equal to no of attachments.
But for sure for approval flow this is not working.
hI Jonathan
PowerApps to SP, really hard.. I cannot solve it..
As I need it urgently, I look into other sources , in the end I use MS Form to SP, it's working.
As for PowerApp..I might look into it look for now, I cannot solve. Maybe later will revisit it. Appreciated your great help.
Quick summary: Thanks to @v-bacao-msft and @jonathanogden for the code snippets. Ultimately, this was the only solution I found; to copy/paste in that code for Approvals in the Append to Array step. Up to this point I have been able to simply construct the json using the GUI to insert DisplayName and AttachmentContent. That doesn't seem to be working now as described below.
Details:
By inspecting the run history, and downloading the json attachment array, I confirmed the json was exact from a working flow to one I'm creating that isn't working. After many hours of trial and error I can confirm at the time of this post, you must copy/paste the code for Approvals; using the GUI doesn't work like is has for the dozen or so approvals I've done up until now:
{
"name":@{items('Apply_to_each')?['DisplayName']},
"content":@{body('Get_attachment_content')['$content']}
}
Otherwise you get an error: The request failed. Error code: 'InvalidRequestContent'. Error Message: 'The request content was invalid and could not be deserialized: 'Unexpected character encountered while parsing value: {. Path 'attachments[0].content', line 1, position 605.'.'.
If you peek at the code, it appears there is a bug or something:
Bad code, using the GUI:
As you can see, highlighted in red, ['$content'] is missing from the GUI method.
It is very frustrating when something that was working so well suddenly stops working!
Hi, @bschult2
Thank you so much.
Did I use "Get content file from path" from Sharepoint and append my array using body ('Get content file from path')? ['$ Content'].
*** Attention: My settings are set for the Portuguese language (BR)
1 - Get Content File from link:
2 - Append
I update the expression and replaced Name with name and ContentBytes to content. However, when I try to open the attachment from the power automate email, it does not open the attachment. What do you think it is the problem?
Thank you,
SBT
Dive into the Power Platform stack with hands-on sessions and labs, virtually delivered to you by experts and community leaders.
Watch Nick Doelman's session from the 2020 Power Platform Community Conference on demand!
User | Count |
---|---|
12 | |
11 | |
7 | |
7 | |
6 |
User | Count |
---|---|
18 | |
17 | |
13 | |
10 | |
9 |