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
PA 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

Power Apps Community Call

Monthly Power Apps Community Call

Did you miss the call?? Check out the Power Apps Community Call here!

secondImage

Experience what’s next for Power Apps

See the latest Power Apps innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Power Platform ISV STudio

Power Platform ISV Studio

ISV Studio is the go-to Power Platform destination for ISV’s to monitor & manage applications post-AppSource publish.

Users online (60,230)