Łukasz Paradowski
Łukasz Paradowski

Reputation: 1

Sending base64 from outlook mail in HTTP - Power Automate

I need to create flow that allows me to send a PDF attachment from Outlook to my server as a parameter.

When I try to send content bytes from the action "Get Attachment(V2)", HTTP returns the error BadRequest.

<!DOCTYPE html>
<html style="height:100%">

<head>
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
    <title> 400 Bad Request
    </title>
    <style>
        @media (prefers-color-scheme:dark) {
            body {
                background-color: #000 !important
            }
        }
    </style>
</head>

<body
    style="color: #444; margin:0;font: normal 14px/20px Arial, Helvetica, sans-serif; height:100%; background-color: #fff;">
    <div style="height:auto; min-height:100%; ">     <div
            style="text-align: center; width:800px; margin-left: -400px; position:absolute; top: 30%; left:50%;">
                    <h1 style="margin:0; font-size:150px; line-height:150px; font-weight:bold;">400</h1>
            <h2 style="margin-top:20px;font-size: 30px;">Bad Request
            </h2>
            <p>It is not a valid request!</p>
        </div>
    </div>
</body>

</html>

My flow:

enter image description here

I tried to use compose and, theoretically, it worked without any problems, but it doesn't send the correct base64 code:

enter image description here

In compose I can see input and output starting with: JVBERi0xLjYNJeLjz9MNCj... and I think this is correct because when I try to put it into base64 converter I can see the original file.

But the HTTP header looks like this:

"b64": "%PDF-1.6\r%����\r\n27 0 obj\n<</Filter/FlateDeco

It doesn't work. On the server side I need to send that base64 code via the API to an external tool called baselinker and I get an error response, while when I put the original base64 JVBERi0xLjYNJeLjz9MNCj into the address as GET parameter it works perfectly.

My third attempt was to format the output of compose in http. So instead of sending that output, I use

base64(outputs('Compose'))

And my last idea was:

base64(outputs('Get_Attachment_(V2)')?['body/contentBytes'])

In both result is the same as earlier: "b64": "%PDF-1.6\r%����\r\n2

Yesterday I tried to do that the other way, I cannot recreate it right now, but there was an error with the info that the request is too long.

Could you please help?

I'd like to have the possibility to use that flow when sending base64 to my server.

Upvotes: 0

Views: 117

Answers (1)

frue
frue

Reputation: 86

in the Compose part, use the expression base64(outputs('Get_Attachment_(V2)')?['body']) to convert the attachment into base64 to be used in Header.

enter image description here

Upvotes: 0

Related Questions