Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Automate - General Discussion
Answered

"ContentBytes: changes to 'Body' after selecting 'Get File Contents' and saving

(0) ShareShare
ReportReport
Posted on by 15

Hello,

 

I am trying to create a PDF attachment that includes form responses. I am using 'When a new response is submitted...', 'Apply to each','Get response details', 'create file', 'get file content', and 'send an email (V2)'.

 

The flow works properly and displays as a PDF attachment both on the e-mail and in my SharePoint site, however, the file is corrupt and will not allow me to view. The only error I can seem to find is that the 'Attachment Content' changes the "ContentBytes" to 'Body' after I save my flow, and does not keep 'Get File Contents'.

Does anyone have solution to this?

 

Thank you!!!
CJ

 

 

Error1.png

Error2.png

Error3.png

 

 

Error4.png

Error5.png

  • Nic-AF Profile Picture
    on at
    Re: "ContentBytes: changes to 'Body' after selecting 'Get File Contents' and saving

    I also noticed "File Content" kept switching to "Body".

    In my case, the pdf file is fine, it's just that I can't preview the PDF in Outlook (gives me error).  I have to double click to open it in Edge or Chrome to see the content.

  • valvon63 Profile Picture
    6 on at
    Re: "ContentBytes: changes to 'Body' after selecting 'Get File Contents' and saving

    A different use case (invoice approvals generating an email with the approved invoice attached to the email), but same issue: "File Content" switching to "Body" in the "Attachment Content" field every time I save the flow. As such, the attachment in the tested or run flow will be a corrupted, unopenable file (regardless of file type) both for the initial approval notification and for the approval email attachment.

     

    I can't find any way to get the "File Content" to stick and not switch to "Body" and thus can't get my attachments into my flow. No idea what is going on.

  • cjp18 Profile Picture
    15 on at
    Re: "ContentBytes: changes to 'Body' after selecting 'Get File Contents' and saving

    THANK YOU! You were a magnificent help!!

  • AliB365 Profile Picture
    91 on at
    Re: "ContentBytes: changes to 'Body' after selecting 'Get File Contents' and saving

    Hi @cjp18 

     

    Yes 😉 the last action can be replaced with a create item on SharePoint instead of OneDrive.  The original html file will need to be created on OneDrive but the PDF can be created on SharePoint.  You might also want to delete the original HTML file on your OneDrive afterwards too with the delete file action.

     

    If you've got any more questions please let me know.  I hope this helps.

     

    Ali B

  • cjp18 Profile Picture
    15 on at
    Re: "ContentBytes: changes to 'Body' after selecting 'Get File Contents' and saving

    Ali B - This solution worked! Thank you so much! Is there any way with utilizing the OneDrive for Business to get these files to save in the SharePoint site rather than my personal OneDrive?

  • Verified answer
    AliB365 Profile Picture
    91 on at
    Re: "ContentBytes: changes to 'Body' after selecting 'Get File Contents' and saving

    Hi @cjp18 

     

    If you want to create a PDF, you need to first create an html file.  Then you can convert the html to PDF using the OneDrive convert file action.  Using the following HTML as an example W3Schools Tryit Editor, we can save that into a compose (you could of course add in your dynamic content from the forms response).  You then create an html file using that content, you can then convert it to PDF and then you take the content from that action to create a new PDF file.

     

    AliB365_0-1672773186641.png

     

    If you've got any more questions please let me know.  I hope this helps.

     

    Ali B

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Michael Gernaey – Community Spotlight

We are honored to recognize Michael Gernaey as our June 2025 Community…

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 566 Super User 2025 Season 1

#2
David_MA Profile Picture

David_MA 516 Super User 2025 Season 1

#3
stampcoin Profile Picture

stampcoin 492