web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

Uploading pdf file using Flows on Power automate

(1) ShareShare
ReportReport
Posted on by 13
Hi 
 
I've been trying to import pdf file (w9 file) to Vendor document attachment entity but it shows "We can't open this file" in Preview and it looks like the file was not imported into D365FO. Tried to open the file (download the file) but it was not readable.
 
Does anyone know how to solve the problem or how to upload pdf file to Vendor master using power automate?
 
My ultimate goal is scan the documents (vendor request form and W9) from procurement team and create the vendor master and attach pdf W9 form to the vendor.
 
Here is the message on Preview.

 
 
Here is my flows.  Maybe Initialize the variable and set the variable parts are not necessary. I was just following guidance from someone's blog.
1. Upload the file
2. Initialize the "FileContents" as String
3&4. For Parse Jason and Compose parts, I just removed unnecessary text from contents. 
 example: 
       Original text >> {"contentBytes":"dGVzdA==","name":"test.txt"}
          After3&4   >> dGVzdA==
5. Set Output from Compose to Variable "FileContents".
6. Adding new row in Vendor document attachments entity. In Archive file field, I convert String to Base64. Used this Expression: base64(variables('FileContents'))
 
 
I have the same question (0)
  • Jonas "Jones" Melgaard Profile Picture
    4,855 Super User 2025 Season 2 on at
    Uploading pdf file using Flows on Power automate
    No problem! I'm glad to hear you got it working (-:
     
    Yes, you need to regenerate the schema after you change the trigger action, since the JSON output schema is not guaranteed to be identical.
    You might not even need to parse the output of the trigger, since Power Automate should already have done it for you.
     
    If it's okay, are you able to create a new question if you have issues after we have fixed this?
    Them other community members can help also (-:
  • Taka.T Profile Picture
    13 on at
    Uploading pdf file using Flows on Power automate
    Thank you Jonas,
     
    This works perfectly!!
    But I got another error message after changing the trigger to email. 
    Do you know why and solution for that?
     
    [
      {
        "message""Invalid type. Expected Object but got Array.",
        "lineNumber"0,
        "linePosition"0,
        "path""",
        "schemaId""#",
        "errorType""type",
        "childErrors": []
      }
    ]
     
     
  • Verified answer
    Jonas "Jones" Melgaard Profile Picture
    4,855 Super User 2025 Season 2 on at
    Uploading pdf file using Flows on Power automate
    You actually don't need to do any type conversion, just use the contentBytes from FileContent; But you have to tell PowerAutomate it's a string.
     
    If you do a base64 on it, it will be a base64 encoded base64 string.
     
    This is my example flow:
    The formula for "Archive file" is "string(triggerBody()?['file']?['contentBytes'])"
     
     
    The attachment will look like this:

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Andrés Arias – Community Spotlight

We are honored to recognize Andrés Arias as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Sohaib Cheema Profile Picture

Sohaib Cheema 823 User Group Leader

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 673 Super User 2025 Season 2

#3
Martin Dráb Profile Picture

Martin Dráb 491 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans