cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
spiderbear
Frequent Visitor

Using Http Post with PDF text

Hi all,

 

I am trying to create a HTTP POST request to upload a PDF.  I have the raw data of the PDF from another API call and now I need to send that to this API.  The API develop says I need to use form-data.

 

This is what I have so far for the body of the HTTP request.  NOTE: I have truncated the pdf contents but am using the full version in the flow.  

 

"body": {
"$content-type": "multipart/form-data",
"$multipart": [
{
"headers": {
"Content-Disposition": "form-data; name=\"file\"; filename=\"test2.pdf\""
},
"body": {
"$content": "%PDF-1.4\r\n%����\r\n%ABCpdf 11314\r\n4 0 obj\r\n<<\n/E 100109\n/H [1939 240]\n/L 101329\n/Linearized 1\n/N 1\n/O 7\n/T 101201\n>> \r\nendobj\r\n\r\nxref\r\n4 43\r\n0000000032 00000 n\r\n0000001809 00000 n\r\n0000001939 00000 n\r\n0000002179 00000 n\r\n0000002378 00000 n\r\n0000002445 00000 n\r\n0000002512 00000 n\r\n0000002615 00000 n\r\n0000002723 00000 n\r\n0000002834 00000 n\r\n0000002960 00000 n\r\n0000005549 00000 n\r\n0000009197 00000 n\r\n0000011207 00000 n\r\n0000014960 00000 n\r\n0000017065 00000 n\r\n0000021560 00000 n\r\n0000024579 00000 n\r\n0000029966 00000 n\r\n0000030818 00000 n\r\n0000035395 00000 n\r\n0000036251 00000 n\r\n0000040805 00000 n\r\n0000041657 00000 n\r\n0000047809 00000 n\r\n0000048665 00000 n\r\n0000051862 00000 n\r\n0000054952 00000 n\r\n0000058027 00000 n\r\n0000059089 00000 n\r\n0000061756 00000 n\r\n0000062815 00000 n\r\n0000065227 00000 n\r\n0000066551 00000 n\r\n0000067608 00000 n\r\n0000070977 00000 n\r\n0000074398 00000 n\r\n0000077545 00000 n\r\n0000080684 00000 n\r\n0000082752 00000 n\r\n0000083814 00000 n\r\n0000086722 00000 n\r\n0000087784 00000 n\r\ntrailer\r\n<<\n/ID [<5087B9534BAC82609920A49E18998302>\n<027AE78A4D6F9893CD75289086E12AF6>]\n/Prev 101191\n/Root 5 0 R\n/Size 47\n/Source (WeJXFxNO4fJduyUMetTcP9+oaONfINN4+d7h6/7WPBwezFukCFPmKMo0G082+WBpB9khgm8VtCFmyd8gIrwOjQRAIjPsWhM4vgMCV\\\r\n8KvVF/K8leNuexNXqGgaF6qM0QDTaJDbZhE/VI3GEg=)\n>> "
}
}
]
}

 

I'm getting the following error:

 

'{"error":{"code":"InvalidContentOperation","message":"Decoding as bytes is not supported for content envelope of type 'multipart/form-data' when the content property is not set."}}'.

 

I don't do a lot of HTTP work so am not sure what the issue is.

 

Thanks.

 

2 REPLIES 2
rrovira
Microsoft
Microsoft

Hello, @spiderbear

 

I encounter a similar error a couple of weeks ago, and I believe the user found the solution by including the base64() (Solved: InvalidContentOperation Error When Posting Documen... - Power Platform Community (microsoft....) I found this blog where they talked about base64() → Binary to Base64 in Microsoft Power Automate/ Microsoft Flow - Debajit's Power Apps & Dynamics 365 B...

 

Let me know if the "base64()" solution helped you! 

 

Cheers, 

Rodrigo

Hi @rrovira ,

Including the base64 function did not work.  I'm not sure what format I am getting the pdf in from the first api.  Does anyone know what format this is?

%PDF-1.4\r\n%����\r\n%ABCpdf 11314\r\n4 0 obj\r\n<<\n/E 100109\n/H [1939 240]\n/L 101329\n/Linearized 1\n/N 1\n/O 7\n/T 101201\n>> \r\nendobj\r\n\r\nxref\r\n4 43\r\n0000000032 00000 n\r\n0000001809 00000 n\r\n0000001939 00000 n\r\n0000002179 00000 n\r\n0000002378 00000 n\r\n0000002445 00000 n\r\n0000002512 00000 n\r\n0000002615 00000 n\r\n00000027

 

The api I need to upload the file to works if I upload the file in the HTTP request body using postman so I'm not sure what format to give pdf in to the receiving api.

 

Cheers,

Theresa.

Helpful resources

Announcements
Process Advisor

Introducing Process Advisor

Check out the new Process Advisor community forum board!

MPA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Users online (3,195)