Skip to main content
Skip table of contents

Thru Content API - File Download

Downloading Files from the Thru REST API

Overview

This guide explains how to download files using our REST API.

The process involves two main steps:

  1. Retrieving file details using a report ID

  2. Constructing the download URL using the obtained information

Prerequisites

Before downloading a file, you will need:

  • A valid report ID

  • The flow endpoint ID

  • API access credentials (if required)

Step 1: Get File Details

First, retrieve the file details using the report ID.

File Details Endpoint

CODE
GET <https://us.thruinc.com/api/Activity/getFileDownloadHistory>

Required Parameters

  • reportId: The unique identifier for the report (e.g., "677e882e01402bc727b075b4")

  • flowEndpointType: Set to 1 for standard downloads

Example Request

CODE
<https://us.thruinc.com/api/Activity/getFileDownloadHistory?reportId=677e882e01402bc727b075b4&flowEndpointType=1>

Step 2: Download the File

Once you have the file details, construct the download URL using the following format.

Download Endpoint

CODE
GET <https://us.thruinc.com/api/Files/1.0/{reportId}/content>

Required Parameters

  • reportId: The same report ID used in Step 1

  • endpointPath: Specifies the flow endpoint in the format "flowendpoint:{endpointId}"

Example Download URL

CODE
<https://us.thruinc.com/api/Files/1.0/677e882e01402bc727b075b4/content?endpointPath=flowendpoint:15938>

Complete Example

  1. Start with a report ID: 677e882e01402bc727b075b4

  2. Get file details using the File Details Endpoint

  3. Use the report ID and endpoint ID to construct the download URL

  4. Send a GET request to the download URL to retrieve the file

Error Handling

Common HTTP status codes you might encounter:

  • 200: Successful download

  • 400: Bad request (check parameters)

  • 401: Unauthorized (check credentials)

  • 404: File not found

  • 500: Server error

Best Practices

  • Always validate the report ID before constructing the download URL

  • Handle large file downloads appropriately by implementing timeout handling

  • Consider implementing retry logic for failed downloads

  • Cache file details when making multiple downloads of the same file

Security Considerations

  • Keep your API credentials secure

  • Validate all input parameters

  • Implement rate limiting if making multiple requests

  • Check file permissions before attempting downloads

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.