Skip to main content

Retrieve a subtotal's definition within a changeset

Available since 2021 Update 5

tip

You can try out this workflow at REST API Playground.

Learn more about MicroStrategy REST API Playground here.

This workflow sample demonstrates how to retrieve a subtotal's definition within a changeset.

tip

An authorization token allows the API layer to hide internal session-related implementations such as managing different project-specific sessions. Once the REST API layer has validated the user's credentials using the specified authentication mode, it initiates a session with the Intelligence server and creates a unique authorization token for the client.

You want to get the definition of an object with the ID of 514C2064DF754990AF60432A1C1E4A77 in the MicroStrategy Tutorial project. The project ID is B7CA92F04B9FAE8D941C3E9B7E0CD754.

For different formats of subtotal expressions, see Retrieve a subtotal's definition.

info

Get the authorization token needed to execute the request with POST /api/auth/login.

Get the project ID from GET /api/projects.

Changesets are used in this workflow. For information on how to create and use changesets, see Changesets.

Get the definition of the specified subtotal ID within a changeset using GET /api/model/subtotals/{subtotalID}

Sample Request Header:

"accept": "application/json"
"X-MSTR-AuthToken": "4bb7n1dhjo860e7tlpchg57hl"
"X-MSTR-MS-Changeset": "2A131744C91B4915B54A61FFDC528F62"

Sample Request Body: Empty

LocationNameDescription
headerX-MSTR-authTokenThe authorization token
headerX-MSTR-MS-ChangesetThe changeset ID.
paramsshowExpressionAsOmitted, tree, or tokens:
- If omitted, the expression is returned in only “text“ formats.
- If tree, the expression is returned in "text" and "tree" formats.
- If tokens, the expression is returned in "text" and "tokens" formats.

Sample Curl:

curl -X GET "https://demo.microstrategy.com/MicroStrategyLibrary/api/model/subtotals/514C2064DF754990AF60432A1C1E4A77" -H "accept: application/json" -H "X-MSTR-AuthToken": "4bb7n1dhjo860e7tlpchg57hl" -H "X-MSTR-MS-Changeset: 2A131744C91B4915B54A61FFDC528F62"

Sample Response Body:

You can view the subtotal's definition in the body of the response.

{
"information": {
"dateCreated": "2022-03-08T03:36:01.097Z",
"dateModified": "2022-03-08T03:36:01.097Z",
"versionId": "C8F384E54BD9E1A415260B9F4A63B643",
"primaryLocale": "en-US",
"objectId": "514C2064DF754990AF60432A1C1E4A77",
"subType": "metric_subtotal",
"name": "Custom_Max"
},
"expression": {
"text": "Revenue",
"tree": {
"type": "object_reference",
"target": {
"objectId": "1116B53103FC4A72BBACBAED388243D6",
"subType": "agg_metric",
"name": "Revenue"
},
"isIndependent": 0
}
},
"dimty": {
"dimtyUnits": [{ "dimtyUnitType": "report_level", "relativePosition": 0 }]
}
}

Response Code: 200 (Subtotal's definition is returned successfully.)