Export to PDF
You can try out this workflow at REST API Playground.
Learn more about Strategy REST API Playground here.
The workflow for exporting a document to PDF includes the following sequence of REST API requests.
- Log in User authenticates into the environment with
POST /api/auth/loginand standard authentication - Get project list User obtains the project list from
GET /api/projects - Create a document instance User executes a specific document in a specific project and creates a document instance
- Export a document to PDF User exports the document to a PDF file
- Log out User calls
POST /api/logoutto close the session
A detailed explanation of each step is provided below:
Log in
Endpoint: POST /api/auth/login
This endpoint allows the caller to authenticate with the Strategy REST Server. You provide the information used to create the session in the body of the request. In this example, you use standard authentication so you need to provide username, password, and loginMode (which specifies the authentication mode to use). If you omit an optional field, the REST Server uses the default value. If the call is successful, the resulting HTTP response returns an HTTP status code 204 and a response header containing X-MSTR-AuthToken, the authorization token that will be used in subsequent requests.

REST API Explorer: https://demo.microstrategy.com/MicroStrategyLibrary/api-docs/index.html#/Authentication/postLogin
Sample Request
-
Request Headers
'Content-Type: application/json'
'Accept: application/json' -
Request Body
{
"loginMode": 1,
"username": "administrator",
"password": ""
} -
Curl
curl -X POST -i -c ~/cookie-jar.txt --header 'Content-Type: application/json' --header 'Accept: application/json' -d '{ \
"loginMode":1, \
"username": "administrator", \
"password": "" \
}' https://demo.microstrategy.com/MicroStrategyLibrary/api/auth/login'
Sample Response
-
Response Headers
{
"pragma": "no-cache",
"x-mstr-authtoken": "nllmm5lpmkjdsj4d4etgdikc6c",
"cache-control": "no-cache, no-store, max-age=0, must-revalidate",
"date": "Wed, 16 Aug 2017 01:42:31 GMT",
"expires": "0",
"content-type": null
}The authorization token
"x-mstr-authtoken"is returned in the response header. It is used in other endpoints to authenticate the user. -
Response Body: Empty
-
Response Code: 204 (Success: No Content)
Get project list
Endpoint: GET /api/projects
This endpoint allows the caller to get the list of projects with the Strategy REST Server. In this example, you get the list of projects in the MicroStrategy Tutorial metadata. You use the authorization token returned during login as the value for X-MSTR-AuthToken. If the call is successful, the resulting HTTP response returns an HTTP status code 200 and a response body containing a list of the active projects that the user session has access to.

REST API Explorer: https://demo.microstrategy.com/MicroStrategyLibrary/api-docs/index.html#/Projects/getProjects
Sample Request
-
Request Headers
'Accept: application/json'
'X-MSTR-AuthToken: nllmm5lpmkjdsj4d4etgdikc6c' -
Request Body: Empty
-
Curl
curl -X GET -b ~/cookie-jar.txt --header 'Accept: application/json' --header 'X-MSTR-AuthToken: nllmm5lpmkjdsj4d4etgdikc6c' https://demo.microstrategy.com/MicroStrategyLibrary/api/projects'
Sample Response
-
Response Body
[
{
"id": "B19DEDCC11D4E0EFC000EB9495D0F44F",
"name": "MicroStrategy Tutorial",
"alias": "",
"description": "MicroStrategy Tutorial project and application set designed to illustrate the platform's rich functionality. The theme is an Electronics, Books, Movies and Music store. Employees, Inventory, Finance, Product Sales and Suppliers are analyzed.",
"status": 0
},
{
"id": "AF09B3E3458F78B4FBE4DEB68528BF7B",
"name": "Human Resources Analysis Module",
"alias": "",
"description": "The Human Resources Analysis Module analyses workforce headcount, trends and profiles, employee attrition and recruitment, compensation and benefit costs and employee qualifications, performance and satisfaction.",
"status": 0
}
]The response body contains information for each project that is returned, including the project ID that you use in later endpoints.
Create a document instance
Endpoint: POST /api/documents/{id}/instances
This endpoint allows the caller to execute a specific document in a specific project and create an instance of that document. In this example, you execute a document called "Casino Analysis" (located in MicroStrategy Tutorial>Shared Reports>Strategy Platform Capabilities>Strategy Report Services>Visual Insight). You use the authorization token returned in step 1 as the value for X-MSTR-AuthToken and provide the project ID and the document ID. In this example, you leave the request body empty. The resulting HTTP response returns an HTTP status 201 and a JSON object containing the instance ID ("mid") of the document.

REST API Explorer: https://demo.microstrategy.com/MicroStrategyLibrary/api-docs/index.html#/Dossiers%20and%20Documents/createDocumentInstance
Sample Request
-
Request Parameters

-
Request Headers
'Accept: application/json'
'X-MSTR-AuthToken: nllmm5lpmkjdsj4d4etgdikc6c'
'X-MSTR-ProjectID: B19DEDCC11D4E0EFC000EB9495D0F44F' -
Request Body: Empty
-
Curl
curl -X POST -i -c ~/cookie-jar.txt --header 'Content-Type: application/json' --header 'Accept: application/json' --header 'X-MSTR-AuthToken: nllmm5lpmkjdsj4d4etgdikc6c' --header 'X-MSTR-ProjectID: B19DEDCC11D4E0EFC000EB9495D0F44F' -d '{}' 'http://demo.microstrategy.com/MicroStrategyLibrary/335FFA9640B5F1C1E0C0F3A469E627A8/instances'
Sample Response
-
Response Body
The REST server returns the instance ID of the document as the value of "mid".
{
"status": 0,
"mid": "0ADDDAF34260EBA5D5FB73BFE5852AC3"
}You can find the detailed parameter definitions in the Response Body on the Swagger page under Response Class -> Model.
-
Response Code: 201 (Success: Created)