Exporting Folders to PDF Asynchronously

This guide explains how to use our API to export folders to PDF. The process involves retrieving a folder ID, initiating the export job, checking the status of the operation, and finally downloading the PDF using the provided URL.

📘

Note

This guide is meant to show you how to asynchronously download large folders that might timeout when exported synchronously. To synchronously download a smaller folder, use this endpoint.

Step 1: Get the Folder ID

To export a folder, you first need its ID. Use the GET /api/v1/folders endpoint to retrieve the folder information. You can optionally use the search query parameter to filter by folder name.

Request:

Endpoint:

GET https://api.getguru.com/api/v1/folders?search={folderName}
  • If using the optionalsearch query parameter, replace {folderName} with the name of the folder you want to search for.

Example Response:

[
    {
      <--more details-->
        "id": "beb2e3af-41b8-4fc4-a832-26fa5f37a7ba",
        "name": "Example Folder"
      <--more details-->
    }
]
  • id: The folder ID to use in the next step.

Step 2: Initiate the Export Job

Use the Bulk Operation API endpoint to start the export process for the folder.

Request:

Endpoint:

POST https://api.getguru.com/api/v1/folders/bulkop

Payload:

{
    "action": {
        "type": "export-folder-pdf"
    },
    "items": {
        "type": "id",
        "itemIds": [
            "beb2e3af-41b8-4fc4-a832-26fa5f37a7ba"
        ]
    }
}
  • action.type: Must be set to export-folder-pdf.
  • items.type: Specify id to indicate you are using folder IDs.
  • items.itemIds: Provide an array of folder IDs you want to export.

Response:

{
    "id": "3e9ffec6-fafd-4a00-8f59-fcba167d625d"
}
  • id: The bulk operation ID used to check the status in the next step.

Step 3: Poll the Status of the Export Job

Use the Bulk Operation Result API endpoint to check the status of the export operation. Replace {bulkOperationId} with the ID returned in the previous step.

Request:

Endpoint:

GET https://api.getguru.com/api/v1/folders/bulkop/{bulkOperationId}

Example Response:

{
    "id": "3e9ffec6-fafd-4a00-8f59-fcba167d625d",
    "items": [
        {
            "url": "https://content.qaapi.getguru.com/files/dn/ca378610-68c6-4e7a-a7f1-7e42d2322fea",
            "statusCode": 200,
            "boardId": "beb2e3af-41b8-4fc4-a832-26fa5f37a7ba"
        }
    ]
}
  • url: The URL to download the exported PDF.
  • statusCode: Indicates the status of the export operation (200 for success).
  • boardId: The ID of the folder associated with this export.

If you receive a 204 (No Content) http status code, the operation has not yet completed. Continue polling until the http status code is 200. If the operation was successful, the statusCode in the response will also be 200. If the operation failed, the http status code will be 200, but the statusCode in the response will return an error code.


Step 4: Download the Exported PDF

Once the export job is complete and you receive a url in the response, use the provided URL to download the PDF.

Example URL:

GET https://content.api.getguru.com/files/dn/ca378610-68c6-4e7a-a7f1-7e42d2322fea

Make an HTTP GET request to this URL to retrieve the exported PDF file.


Summary

  1. Retrieve the folder ID using the GET /api/v1/folders endpoint.
  2. Use the Bulk Operation API to initiate the export-folder-pdf action.
  3. Poll the GET /api/v1/folders/bulkop/{bulkOperationId} endpoint to monitor the export's progress.
  4. Once complete, download the PDF from the provided URL.

If you encounter any issues, please contact our support team for assistance.