Downloading Files using the MFT Content API
This topic describes 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 need the following:
- A valid report ID
- The flow endpoint ID
- API access credentials (if required)
To download Files using the MFT AFT Content API:
Step 1: Get File Details
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 (For example,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 formatflowendpoint:{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
Was this topic helpful?