cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Helper I
Helper I

add email attachment with files from Form

Hello,

 

I'm building an approval flow with guidance from the following link:

https://www.bythedevs.com/post/working-with-files-on-ms-forms-in-ms-power-automate

 

and my flow is like this :

 

微信截图_20200904101231.png

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

when I run the flow it returns an error:

The request failed. Error code: 'InvalidRequestContent'. Error Message: 'The request content was invalid and could not be deserialized: 'Could not find member 'ContentBytes' on object of type 'ApprovalsConnectorAttachment'. Path 'attachments[0].ContentBytes', line 1, position 454.'.'.

 

I think it has something to do with the append to attachment array:

微信截图_20200907115603.png

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

for the Content/ContentBytes, I have tried the following:

"Content": File content

"Content": base64(File content)

"ContentBytes": File content

"ContentBytes": base64(File content)

none of the above works, I don't know what to do now.

 

Can anyone help me with this?

Thanks in advance!

 

1 ACCEPTED SOLUTION

Accepted Solutions

@Derek4 No worries we will get around in can you post a screenshot of how passed the attachment?

 

Perhaps you might want to decorate the 'File Content' with the base64() function.

 

{
"Name": @{items('Apply_to_each')?['DisplayName']},
"Content": @{base64(body('Get_file_content'))}
}

 

Untitled.png

 

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!

View solution in original post

13 REPLIES 13
Helper I
Helper I

Hi! When I create my file from an MS Form I follow these steps:

 

Parse JSON of file upload 

Compose Variable Name 

Get files contents using path  - /Apps/Microsoft Forms/MYFOLDER/Question/@{outputs('Compose')} using the variable i just composed 

Then I create the file in SharePoint, but the get file contents could be used in the email attachment. 

 

Hope this helps

Ben 

 

 

 

BenRenshaw_0-1599541822347.png

 

Hi Ben, I tried your way:

微信截图_20200908151350.png

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

but the flow still fails, and returns this error:

微信截图_20200908151555.png

 

 

 

 

 

 

 

Looks like the same error.  what is your expression in the append to array? I think this maybe where the problem is.

In your form - how many attachments are being uploaded? Is it multiple? I am not appending to the array, you can just add the attachments in the send email? 

I'm uploading multiple (2) attachments, the flow I'm building requires multiple attachments. I once tried single attachment, the flow run successfully but the attachment is corrupted and I can open it.

Helper I
Helper I

I think youre on the right track, if you click the T it will allow you to input an entire array. 

This article is better at explaining than me!! https://flow.microsoft.com/en-us/blog/multiple-attachments-single-email/

BenRenshaw_0-1599551342595.png

BenRenshaw_1-1599551397617.png

 

 

Community Support
Community Support

Hi @Derek4,

 

The "ContentBytes": File content  could work:Annotation 2020-09-08 104646.jpg

 

Which step reports the error? Get file content action works well?

The request failed. Error code: 'InvalidRequestContent'. Error Message: 'The request content was invalid and could not be deserialized: 'Could not find member 'ContentBytes' on object of type 'ApprovalsConnectorAttachment'. Path 'attachments[0].ContentBytes', line 1, position 454.'.'.

 

Best Regards,
Community Support Team _ Lin Tu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@Derek4 Approvals action does not recognize contentbytes and so you need to use the content key to pass the file content. 

 

Please configure the action with reference to screenshot below:

 

Untitled.png

 

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!

 

 

I think it's the add attachment to approval failed, Get file content action is successful.

微信截图_20200908161338.png

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

@Derek4 The Error tells me "Could not find ContentBytes" please change ContentBytes to Content  with reference to the screenshot in my previous update. 

 

Note: Approvals action does not recognize ContentBytes and so you need to use the Content key to pass the file content. 

 

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!

@CFernandes  I tired your way, the flow is successful, but the attachment is corrupted:

微信截图_20200908162354.png

 

@Derek4 No worries we will get around in can you post a screenshot of how passed the attachment?

 

Perhaps you might want to decorate the 'File Content' with the base64() function.

 

{
"Name": @{items('Apply_to_each')?['DisplayName']},
"Content": @{base64(body('Get_file_content'))}
}

 

Untitled.png

 

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!

View solution in original post

@CFernandes  It's very strange, I did exactly what you told me and again the flow succeed but the attachment corrupted. But when I change the Base64(File content) to File content, the flow succeed and the attachment is OK.

 

I did use Content: File content before and it just like "the flow succeed but the attachment corrupted", I don't know what's wrong but now it working as planned. 

 

Thank you!

@Derek4 I am glad that you could resolve the problem. 🙂

Helpful resources

Announcements
PP Bootcamp Carousel

Global Power Platform Bootcamp

Dive into the Power Platform stack with hands-on sessions and labs, virtually delivered to you by experts and community leaders.

secondImage

Power Platform Community Conference On Demand

Watch Nick Doelman's session from the 2020 Power Platform Community Conference on demand!

MPA Community Blog

Power Automate Community Blog

Check out the community blog page where you can find valuable learning material from community and product team members!

Top Solution Authors
Users online (6,486)