Skip to main content

embeddingComponent.environments namespace

Available since 2021 Update 9 (May 2023)

This is the entry point of the Native Embedding SDK.

APIs

The create environment API

Function

async microstrategy.embeddingComponent.environments.create(props)

Input Parameters

Parameter NameData TypeDescriptionIs Required
props.serverUrlStringThe base URL of the Library servertrue
props.getAuthTokenfunctionThe function for getting the login token.
This function is similar to getAuthToken in microstrategy.dossier.create.
In 2021 Update 9, MicroStrategy only supports auth token. You can get the auth token with any auth mode.
true

Response

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

Example

Find the getAuthToken function in the Native Embedding SDK doc

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

API Errors

The errors caught in this function include:

Error CaseError CategoryHandling ModuleError Handling
The input parameter fails input validationInvalid inputNative Embedding SDKCaught by the catch() of the promise object
There is already another existing environmentUnsupported caseNative Embedding SDKCaught by the catch() of the promise object
Invalid authentication info or incorrect CORS settingOtherNative Embedding SDKCaught by the catch() of the promise object
Other REST API errorsOtherNative Embedding SDKCaught by the catch() of the promise object

The destroy environment API

Function

async microstrategy.embeddingComponent.environments.destroy(environment)

Input Parameters

Parameter NameData TypeDescriptionIs Required
environmentMstrEnvironment classThe environment returned by the create function.
When it’s not provided, the Native Embedding SDK destroys all environments in the current page.
true

Response

This API returns a promise object, that resolves to nothing.

Example

try {
await microstrategy.embeddingComponent.environments.destroy(environment);
} catch (error) {
// Your own error handling logic
}

API Errors

The errors caught in this function include:

Error CaseError CategoryHandling ModuleError Handling
The environment doesn't exist in the client’s pageInvalid inputNative Embedding SDKCaught by the catch() of the promise object