Skip to main content

Notifications

Community site session details

Community site session details

Session Id : yP6a2AO9GAeO3meYAQrbhN
Power Automate - Using Flows
Answered

Convert Base64 from a RestAPI JSON into a PDF

Like (1) ShareShare
ReportReport
Posted on 27 Feb 2023 15:29:20 by 18

Hi there

 

I have a small problem which I can not solve.

 

I receive a document in Base64 via a REST API. According to other forum posts and instructions I found, it should be possible to convert the data to binary and then save it as a document on Sharepoint.

The flow goes through without a problem as well. Only the document (PDF) is not correct on Sharepoint and cannot be viewed. The Base64 code does not seem to have been changed to binary.

HTTPS.jpgComposing.jpg

 

The final result is still just a Base64-Code. I tested it to transfer it to a PDF with a simple online-tool. It works and it gives the correct result.

 

Does anyone have an idea what this could be?

 

  • LSB Profile Picture
    33 on 11 Sep 2024 at 11:18:51
    Convert Base64 from a RestAPI JSON into a PDF
    What exactly do you mean? You deleted every - and [] in the base64 stream before you gave it to the compose node?
     
    Can you provide me with a screenshot of your working flow?
  • Verified answer
    Gotorus Profile Picture
    18 on 13 Jun 2023 at 07:06:52
    Re: Convert Base64 from a RestAPI JSON into a PDF

    Hey Troels

    Thanks for your answer!

    I tried this, but it was not a different result.

    But I found the problem. It was very simple. I had to remove the "- and []-characters. Then it worked.

  • Troels Profile Picture
    4 on 24 Apr 2023 at 08:57:55
    Re: Convert Base64 from a RestAPI JSON into a PDF

    Hey Gotorus

    I had a similar problem trying to attach a pdf when sending an email. I realized that the output of the Base64ToBinary function is an object in the below format (which seems to be the way Power Automate represents binary data):

     
    {
      "$content-type": "application/octet-stream",
      "$content": <the base64-string>
    }
     
    So since the SharePoint action is expecting a binary-type object for "File Content", I think the issue is that the output of the "Base64ToBinary Label" action is not in the same format as above but rather something like this:
     
    {
      "$content-type": "application/pdf",
      "$content": {
        "$content-type""application/octet-stream",
        "$content": <the base64-string>
      }
    }
     
    Try to use just the base64-string for the "$content" of the "Base64ToBinary Label" action:
    {
      "$content-type": "application/pdf",
      "$content": outputs('Compose_Label_Base64')
    }

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

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Congratulations to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,771 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 66,091 Most Valuable Professional

Leaderboard

Featured topics

Restore a deleted flow