This article describes the External Report Download API endpoint available for MI v7.2.1+, which allows downloading an External Report as a file; i.e., PDF, image, Excel, PowerPoint, and more, generated on demand by the source BI tool:
/api/element/id/{elementId}/segment/{dimensionId}/download/state/{state}: Discover available formats, generate token for file access, initialize file generation, check generation status, and download the generated file.
The described API endpoint is not available in the API Toolkit and must be accessed via direct API calls.
PREREQUISITES:
- The Element must be an External Report.
- The authenticated user must have view access to the Element.
- The source plugin must support the requested format. Use the
formatsstate to discover what is available for a given Report.
TABLE OF CONTENTS:
1. Endpoint Overview
Method: GET
Path: /api/element/id/{elementId}/segment/{dimensionId}/download/state/{state}
A single endpoint drives the entire download workflow. Call the endpoint sequentially through five states to discover available formats, generate the file, and download it. The token returned by the init state is required for run, check, and get.
2. Supported File Formats
The format key passed in format= must match the capability value the plugin advertises for the given External Report. If the format is unavailable, the call returns 400 Invalid format.
| Format key | Plugin capability | File extension | Typical use |
|---|---|---|---|
image | IMAGE | .png | Static screenshot |
pdf | PDF | .pdf | Standard PDF export |
apdf | APDF | .pdf | Accessible (tagged) PDF |
ppt | PPT | .pptx | PowerPoint |
xls | XLS | .xlsx | Excel |
doc | DOC | .docx | Word |
csv | CSV | .csv | Tabular data |
xml | XML | .xml | XML payload |
mhtml | MHTML | .mhtml | Web archive |
3. Download Workflow
Each call advances or checks the download session. The session is identified by a token issued in init and expires after 5 minutes.
3.1. List All Available Formats (formats)
GET request to /api/element/id/{elementId}/segment/{dimensionId}/download/state/formats returns the formats supported by the specified External Report, as declared by the source plugin.
Sample response:
{
"status": "OK",
"formats": [
"image", "pdf", "csv", "xls"
]
}
3.2. Initialize a Download Session (init)
GET request to /api/element/id/{elementId}/segment/{dimensionId}/download/state/init creates a short-lived token bound to the calling user. The token is returned URL-encoded.
Sample response:
{
"status": "OK",
"token": "<URL-encoded token>"
}
3.3. Trigger File Generation (run)
GET request to /api/element/id/{elementId}/segment/{dimensionId}/download/state/run?token=<token>&format=<format> generates the requested file by calling the source plugin.
- The call may take up to 30 minutes, depending on the source BI tool, the Report size, and any configured filters. Poll
checkfrom a separate connection while run is in progress. - On failure,
checkandgetreturn ERROR.
Sample response:
{
"status": "OK"
}
3.4. Poll for Completion (check)
GET request to /api/element/id/{elementId}/segment/{dimensionId}/download/state/check?token=<token> returns one of three statuses:
IN PROGRESS: Generation is not yet finished. Continue polling.READY: The file is generated and ready to download.ERROR: Generation failed. Do not callgetafter ERROR.
Sample response:
{
"status": "READY"
}
3.5. Retrieve the File (get)
GET request to /api/element/id/{elementId}/segment/{dimensionId}/download/state/get?token=<token>&format=<format> downloads the file as an HTTP attachment. The filename follows the pattern <element-name>.<extension>, with reserved characters stripped.
- After a successful download, the session is consumed. Calling
getagain with the same token returns an error. - The response
Content-Typeis set to the file's MIME type, andContent-Dispositionis set toattachment; filename="..." - If run has not finished, get returns
{ "status": "IN PROGRESS" }. If run failed, get returns{ "status": "ERROR" }.
4. Response Fields
| Field | Value type | Description |
|---|---|---|
status | string | OK, READY, IN PROGRESS, or ERROR depending on state. |
formats | array of string | Returned by formats state only. List of format keys the Report supports. |
token | string | Returned by init state only. URL-encoded download session token. |
message | string | Returned on error responses only. Human-readable error description. |
For state=get, a successful response contains the raw file binary; no JSON envelope is returned.
5. Request Parameters
| Parameter | In | Required | Description |
|---|---|---|---|
elementId | path | Yes | The Element ID. Must be an External Report. |
dimensionId | path | Yes | The Dimension Value ID, or 0, for unsegmented Elements. |
state | path | Yes | One of: formats, init, run, check, get. |
token | query | Required for run, check, get | The token returned by init, URL-encoded. |
format | query | Required for run, get | Format key from the Supported File Formats table. |
6. Error Responses
| HTTP code | Status / Message | Cause |
|---|---|---|
| 400 | Invalid state | state is not one of the five known values. |
| 400 | Invalid token | token is missing or malformed. |
| 400 | No downloads available | The Report has no download capabilities reported by the plugin. |
| 400 | Invalid format | The supplied format is not in the Report's capability list. |
| 400 | Not implemented for this Element Type | The Element is not an External Report. |
| 400 | Download failed | Token expired, generation aborted, or no file produced. |
| 403 | Element not allowed | The authenticated user does not have view access to the Element. |
| 404 | Element not found | No Element exists with the given elementId and dimensionId. |
7. End-to-End Example
The following example downloads a PDF for an External Report with elementId = 1042 and dimensionId = 0:
GET /api/element/id/1042/segment/0/download/state/formats->{ "status": "OK", "formats": ["image", "pdf", "csv"] }GET /api/element/id/1042/segment/0/download/state/init->{ "status": "OK", "token": "abcDEF123%3D" }GET /api/element/id/1042/segment/0/download/state/run?token=abcDEF123%3D&format=pdf(may take seconds to minutes) ->{ "status": "OK" }GET /api/element/id/1042/segment/0/download/state/check?token=abcDEF123%3D->{ "status": "READY" }GET /api/element/id/1042/segment/0/download/state/get?token=abcDEF123%3D&format=pdf->200 OK Content-Type: application/pdf Content-Disposition: attachment; filename="Sales Dashboard.pdf" <binary PDF bytes>
After step 5, the session is consumed. Subsequent calls with the same token return an error.
NOTES:
- Per-format capability is plugin-driven. If a format does not appear in
formats, check the source BI tool's connector capabilities or contact the plugin maintainer. - Token expires in 5 minutes. Call
runpromptly afterinit. If the token expires beforerunfinishes, the file is discarded. - Plugin generation can take up to 30 minutes. For large Reports, expect long-running calls. Poll
checkfrom a separate connection rather than waiting onrun. - One download per session. After
getsucceeds, the session is consumed. To download again, repeat the workflow frominit. - External Reports only. Metrics, Reports, Datasets, and Multi-Metric Charts return
400 Not implemented for this Element Type.