Introduction

In modern enterprise applications, generating documents like PDFs dynamically and storing them securely is a common requirement. Power Apps, combined with Azure API Management and SharePoint Online, offers a powerful way to achieve this. In this article, I will walk through how to generate a PDF from Power Apps using a custom API, route the request through an API Management Gateway to an on-premise API, and finally upload the generated PDF to SharePoint Online using certificate-based authentication.

Overview

This solution involves the following components:

Architecture

Picture1

In this architecture, Power Apps will trigger an API via Power Automate (custom connector), and the Inputs for this API will be generated by Power Apps. The JSON input will be generated from Power Apps based on the input selection from UI, and the Json file will be saved in SharePoint Online. The “Input” is the ItemId with which the Json file is saved in the SharePoint Online. The .NET API accepts the input, i.e., ItemId of the JSON file, and downloads the JSON file from the SharePoint Online.

Picture2

Detailed Walkthrough

1.Designing the Power App

2.Creating the Custom Connector in Power Automate

3.Setting Up Azure API Management (APIM) Gateway

4.Implementing the On-Premise API

5.Uploading to SharePoint Online Using Certificate Authentication

6.Calling the API from Power Apps

7.(Optional) Logging and Monitoring

Common Error Responses and Solutions

While working with a custom API, below is the reference of common error responses and their solutions.

1. 400 Bad Request

2. 401 Unauthorized

3. 403 Forbidden

4. 404 Not Found

5. 500 Internal Server Error

6. 503 Service Unavailable

Tips & Best Practices

Conclusion

This architecture provides a secure, scalable, and maintainable way to generate and store PDFs from Power Apps. By leveraging Azure API Management and certificate-based authentication, you ensure enterprise-grade security and flexibility. Whether you are automating invoice generation, report creation, or any other document workflow, this approach can be adapted to fit a wide range of business needs.