Skip to main content

MstrEnvironment class

Available since 2021 Update 9 (May 2023)

The instance of this class is the object returned from the microstrategy.embeddingComponent.environments.create() function, which allows access to the MicroStrategy application. MstrEnvironment class represents one MicroStrategy Library Application identified by a URL.

APIs

The load dashboard API

Function

async loadDossier(props)

Input Parameters

Parameter NameData TypeDescriptionIs Required
props.projectIdStringThe project ID, which must be a GUID.true
props.objectIdStringThe dashboard ID, which must be valid. If the ID is a document, report, or bot ID, an error is reported.true
props.instanceIdStringThe dashboard instance ID, if it already exists.false
props.applicationIdStringthe dashboard application ID, if not specified, the default application will be usedfalse

The projectId + objectId is used as the dashboard identifier. If the function is called twice with the same parameter, the same MstrDossier object is returned in the callback.

Response

This API returns a promise object that resolves to a MstrDossier object.

Example

try {
const environment = await microstrategy.embeddingComponent.environments.create({
serverUrl: "https://demo.microstrategy.com/MicroStrategyLibrary",
getAuthToken: () => {
// Logic similar to the existing Native Embedding SDK.
},
});
// Begin here
const dossier = await environment.loadDossier({
projectId: "B19DEDCC11D4E0EFC000EB9495D0F44F",
objectId: "D9AB379D11EC92C1D9DC0080EFD415BB",
});
} catch (error) {
// Your own error handling logic
}

API Errors

Error CaseError CategoryHandling ModuleError Handling
The input parameter fails input validationInvalid inputNative Embedding SDKCaught by the catch() of the promise object
Other REST API errorsOtherNative Embedding SDKCaught by the catch() of the promise object

The destroy dashboard API

Function

async unloadDossier(dossier)

Input Parameters

Parameter NameData TypeDescriptionIs Required
dossierMstrDossier classThe MstrDossier object created by the loadDossier functiontrue

Response

This API returns a promise object that resolves to a MstrDossier object.

Example

try {
// The logic to generate a MstrDossier object
await environment.unloadDossier(dossier);
} catch (error) {
// Your own error handling logic
}

API Errors

Error CaseError CategoryHandling ModuleError Handling
The input parameter isn’t a valid dashboard objectInvalid inputNative Embedding SDKCaught by the catch() of the promise object

The load bot API

Function

async loadBot(props)

Input Parameters

Parameter NameData TypeDescriptionIs Required
props.projectIdStringThe project ID, which must be a GUID.true
props.objectIdStringThe bot ID, which must be valid. If the ID is a dashboard, document or report ID, an error is reported.true
props.applicationIdStringthe bot application ID, if not specified, the default application will be usedfalse

The projectId + objectId is used as the bot identifier. If the function is called twice with the same parameter, the same MstrBot object is returned in the callback.

Response

This API returns a promise object that resolves to a MstrBot object.

Example

try {
const environment = await microstrategy.embeddingComponent.environments.create({
serverUrl: "https://demo.microstrategy.com/MicroStrategyLibrary",
getAuthToken: () => {
// Logic similar to the existing Native Embedding SDK.
},
});
// Begin here
const bot = await environment.loadBot({
projectId: "B19DEDCC11D4E0EFC000EB9495D0F44F",
objectId: "E9AB379D11EC92C1D9DC0080EFD415BB",
});
} catch (error) {
// Your own error handling logic
}

API Errors

Error CaseError CategoryHandling ModuleError Handling
The input parameter fails input validationInvalid inputNative Embedding SDKCaught by the catch() of the promise object
Other REST API errorsOtherNative Embedding SDKCaught by the catch() of the promise object

The get authToken API

Function

getAuthToken()

Response

This API returns the authentication token obtained by the MstrEnvironment.

Example

try {
const environment = await microstrategy.embeddingComponent.environments.create({
serverUrl: "https://demo.microstrategy.com/MicroStrategyLibrary",
getAuthToken: () => {
// Logic similar to the existing Native Embedding SDK.
},
});
// Get authentication token
const authToken = environment.getAuthToken();
} catch (error) {
// Your own error handling logic
}