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:
Retrieving file details using a report ID
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
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
<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
GET <https://us.thruinc.com/api/Files/1.0/{reportId}/content>
Required Parameters
reportId
: The same report ID used in Step 1endpointPath
: Specifies the flow endpoint in the format "flowendpoint:{endpointId}"
Example Download URL
<https://us.thruinc.com/api/Files/1.0/677e882e01402bc727b075b4/content?endpointPath=flowendpoint:15938>
Complete Example
Start with a report ID:
677e882e01402bc727b075b4
Get file details using the File Details Endpoint
Use the report ID and endpoint ID to construct the download URL
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