Create file correctly in SharePoint from Dataverse connector using Power Automate | Using base64ToBinary expression

If you are creating a file from Attachment from a Dynamics 365 CRM record and trying to load it in SharePoint and it doesn’t get created/read correctly?

Although, it might appear it was correctly uploaded, it might not open correctly and could look like this.


Consider this scenario – You want to store the Documents that you attach in Notes to SharePoint.

  1. Let’s assume you are uploading this PDF document on the Note and now you want to upload this to SharePoint.

  2. And you have a Flow to send this document to SharePoint which runs when you create a Note in Dataverse (Dynamics 365 CRM)
    Now, the Create file action in SharePoint will look something like this –

    If you use the new Dataverse [green] connector to pick up the attachment from the Note created in Dynamics CRM –

    It’ll let you add the Document to the File context in SharePoint’s Create file action.
    This is triggerOutputs()?[‘body/documentbody’] if you hover over it.

  3. And upon running this Flow, the document will be created in SharePoint.

  4. But when, you open the file, you’ll find this error that you can’t read the file although it appears that is was uploaded correctly.

  5. And also, the browser can’t open it either even if you download it.

Use base64ToBinary conversion

Here’s a step to create a File in SharePoint in your mentioned SharePoint library –

  1. In order to correctly pass this through, use the base64ToBinary expression in the Create file’s File Content field.

  2. And in base64ToBinary, put the Document so that it looks like this – “base64ToBinary(triggerOutputs()?[‘body/documentbody’])

  3. And when you re-run the test, the document will be created in the same way.

    And now when you open it, it’ll open properly.

    Hope this solves the issue!

Dataverse (Legacy) connector

Here’s a difference you’ll notice in when you are using the Dataverse (Legacy) [gray colored] connector –

  1. If you are using the older Dataverse Legacy connector to pick your file from Dynamics 365.

  2. And try to add it to the Create file in SharePoint’s connector –

  3. It’ll let you add it but not let you save it.

    You’ll face a validation error – “Flow save failed with code ‘OpenApiOperationParameterValidationFailed’ and message ‘Input parameter ‘body’ validation failed in workflow operation ‘Create_file’: The parameter with value ‘”@triggerOutputs()? [‘body/documentbody’]”‘ in path ‘body’ with type/format ‘String/bytes’ is not convertible to type/format ‘String/binary’.’.

    Here’s a detailed post of a scenario posted by my friend Linn:

Hope this was helpful! Here are some more Dynamics 365 posts which you might be interested in –

  1. Enable SharePoint Online integration Dynamics 365 | Power Platform Admin Center
  2. Dynamics 365 Storage Utilization | Dataverse Storage | Power Platform Admin Center
  3. Use Hierarchy in Roll Up Fields in Dynamics 365 CRM
  4. Filter records in a View owned by a Team you are a member of | Dynamics 365 CRM
  5. Get GUID of the current View in Dynamics 365 CRM JS from ribbon button | Ribbon Workbench
  6. Dynamics 365 App For Outlook missing on SiteMap in CRM? Use shortcut link [Quick Tip]
  7. Import lookup referencing records together in Dynamics 365 CRM | [Linking related entity data during Excel Import]
  8. Excel Importing Notes (Annotation) entity in Dynamics 365 CRM
  9. Enable/Disable the need to Approve Email for Mailboxes in Dynamics 365 CRM CE
  10. Call Azure Function from Dynamics 365 CRM using Webhooks
  11. Show Ribbon button only on record selection in Dynamics CRM
  12. Accessing multiple occurrences of a field in Business Process Flow using JS in D365 CRM

Thank you!!


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.