Skip to main content
All CollectionsAPI
How to Fetch a PDF Report Through the Orbify API
How to Fetch a PDF Report Through the Orbify API
Michał Wieczorek avatar
Written by Michał Wieczorek
Updated over 3 months ago

Fetching a PDF report through the Orbify API is a simple process that involves two main steps: creating the report and then using the API to retrieve the PDF. This guide will walk you through each step, ensuring that you can seamlessly generate and download your PDF reports.

Step 1: Creating the report

Before you can fetch a PDF report, you need to create a project within the Orbify platform. This project serves as the foundation for generating the report.

Creating a Project:

  • Via the Orbify Platform: If you're working within the Orbify Platform, you can follow the steps outlined in the "How to Create a Project" article to set up your project. This process involves defining the project's parameters, adding the necessary data, and configuring any specific settings.

  • Via the API: Alternatively, if you prefer a programmatic approach, you can create the project directly using the Orbify API. This method is ideal for automating project creation as part of a larger workflow.

    Once your project is created and the data is processed, the system will generate a downloadable PDF report associated with that project.

Step 2: Fetch the PDF Report Through the API

After your project is created and the report is generated, you can retrieve the PDF report using the Orbify API. This is done through the "Get Report PDF" API endpoint.

Steps to Fetch the PDF Report:

  1. Call the Get Report PDF Endpoint: Use the specific API endpoint to request the PDF report associated with your project. When you make this API call, the response will vary depending on the status of the report generation.

  2. Understand the API Responses:

    • Report Still Generating: If the report is still being generated, the API will return a 200 OK response along with a message indicating that the report is not yet ready. In this case, you should wait a bit longer and try the request again later.

    • Report Ready for Download: When the report is ready, the API will return a 307 TEMPORARY REDIRECT status code. This redirect points to the URL where you can download the PDF file. Follow this redirect to retrieve your report.

    • Request Errors: If there are any issues with your request, the API will return a 422 VALIDATION ERROR response. This status will include details on what went wrong, such as missing parameters or incorrect data formatting, allowing you to correct the request and try again.

Example:

curl --location 'https://mjolnir.api.orbify.app/api/v2/{YOUR_APPLICATION_IDENTIFIER}/reports/{REPORT_ID}/pdf' --header 'X-Access-Token: {YOUR_API_KEY}'

Conclusion

Fetching a PDF report through the Orbify API is a straightforward process that involves creating a project and then using the API to retrieve the report. By understanding the different response types provided by the API, you can effectively manage the report generation process and ensure that your PDF is ready for download when needed. This method is particularly useful for integrating report generation into automated workflows, enhancing the efficiency and functionality of your applications.

Did this answer your question?