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

Power App view pdf file returned from GET request to REST API

I'm trying to display a pdf recovered using a GET request to a RESTful API in the Power Apps Pdf Viewer.

 

I've created a customer connector for the GET request which returns a pdf in the response body. I can see this API call is works fine in the test mode of the customer connector ( as well as in Postman).

 

I don't know a way of getting to the response body of the connector call in Power Apps so I've created a Power Automate flow to call the API and return the pdf in file type response property of a "Respond to Power App or Flow" action (see below).

 

I then call the flow from an OnSelect event of a Power App button and use UpdateContext to assign the response to a local variable.

 

I'd rather hoped that simply assigning the document property of the pdf viewer to the local variable but alas not. The api appears to call ok (Power Apps seems to think for a few secs) but the pdf viewer doesn't display the file and no error messages appear.  

 

Can anyone advise how I can get the pdf response of my API call to display in the Power App pdf viewer please?

 

Thank you

 

Jonathan

 

 

flow.jgp.JPG

1 ACCEPTED SOLUTION

Accepted Solutions
basa314
Frequent Visitor

Now solved.

 

Created a customer connector which I called from Automate and base64 encoded the pdf in the response body into a variable string using  base64(outputs('report')?['body'])  Then returned the string to Power Apps  with "data:application / pdf;base64," as a prefix.

 

Calling the Automate flow from Power Apps and assigning the return string to the document property of the Pdfviewer2 displayed the pdf.

 

 

 

View solution in original post

1 REPLY 1
basa314
Frequent Visitor

Now solved.

 

Created a customer connector which I called from Automate and base64 encoded the pdf in the response body into a variable string using  base64(outputs('report')?['body'])  Then returned the string to Power Apps  with "data:application / pdf;base64," as a prefix.

 

Calling the Automate flow from Power Apps and assigning the return string to the document property of the Pdfviewer2 displayed the pdf.

 

 

 

View solution in original post

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Microsoft Ignite 768x460.png

Find your focus

Explore the latest tools,training sessions,technical expertise, networking and more.

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

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 (2,138)