Import and export using the API

Contents[Hide]

1. Overview

You can use the API to import and export DBIE files in the same way you can through the UI in Dundas BI and Logi Symphony's Managed Dashboards & Reports. This article will show how to import and export projects and settings using the following:

  • The Dundas BI Engine and .NET
  • REST Services
  • The JavaScript API

Some of the objects that can be imported and exported are:

  • Accounts
  • File System Entries
  • Groups
  • Custom Attributes
  • Tokens
  • Tenants

For a full list of the objects that can be exported, click here.

2. Getting started

There are three ways to import and export the objects:

  • Using the Dundas BI Engine and referencing the Dundas .NET assemblies from the instance's SDK folder or NuGet.
  • Using REST Services. The advantage of this method is no references are required, and the code can be written in any language capable of making HTTP requests.
  • Using the JavaScript API. This method requires that the script be run from within the application.

3. Using the Dundas BI engine and .NET

To call the import and export functionality in .NET, you will need the following on your development machine:

  • A version of Microsoft .NET compatible with your version of the application
  • A .NET IDE, preferably Microsoft Visual Studio

Version 9 and below installed on Windows use the .NET Framework, while version 10 and higher and all other platforms use .NET Core, now also known as simply .NET. To confirm, check the system requirements for your version of the application.

You will need to reference the following assemblies, which can optionally be found in the SDK folder in the instance as indicated:

  • [InstanceDirectory]\sdk\bin\Dundas.BI.Core.dll
  • [InstanceDirectory]\sdk\bin\Newtonsoft.Json.dll

You can also add the NuGet packages for these assemblies.

3.1. Importing in .NET

When importing, start the Dundas BI Engine, and log on with a user account that has administrator privileges. The Import method of the ITransferService is used to import objects in .NET. This method takes a ImportConfig object.

The following example demonstrates how to start the Dundas BI Engine, and import a file from C:\Temp\Project.dbie containing a project with the specified ID.

using Dundas.BI;
using Dundas.BI.AccountServices
using Dundas.BI.Services;
using Dundas.BI.Transfer;
using Dundas.BI.FileSystem;
using System.Collections.ObjectModel;
   ...

try
{
    MultithreadedCallerContextService callerContextService = new MultithreadedCallerContextService();
    // Create the CreateEngineOptions object.
    CreateEngineOptions createEngineOptions = new CreateEngineOptions();
    // Path to the application's data folder.
    CreateEngineOptions.AppDataPath = appDataPath;
    // Connection string for the application database.
    CreateEngineOptions.AppDbConnectionString = appDbConnectionString;
    // The caller context service.
    CreateEngineOptions.CallerContextService = callerContextService;
    // Unique identifier for the engine instance.
    CreateEngineOptions.HostIdentifier = "CreateExportFiles";

    EngineManager.CreateEngine(createEngineOptions);

    // Start the engine.
    EngineManager.StartEngine();
    // Set the current context to null.
    using (Engine.Current.GetService<ICallerContextService>().CreateAndSetCurrentContext(null))
    {
        LogOnResult logOnResult = Engine.Current.GetService<ILogOnService>().LogOn(
            // The account name. Type: String
            "admin",
            // The password. Type: String
            "1234",
            // Delete other sessions for the logon to succeed. Type: Boolean
            true,
            // Culture to associate with the session, or null. Type: CultureInfo
            null
        );
        // Set the new logon session ID to use.
        Engine.Current.GetService<ICallerContextService>().CurrentContext.SetCurrentSessionId(
            logOnResult.Session.Id
        );
        // The ID of the project to import.
        Guid projectId = new Guid("3cc17f9d-b796-45da-a799-c529ea636401");
        // Create an export configuration file.
        ImportConfig importConfig = new ImportConfig(@"C:\Temp\Project.dbie");
        // Add the ID of project you would like to import.
        importConfig.FileSystemEntryIds.Add(projectId);
        // Add the ID of project you would like to export.
        importConfig.FileSystemEntryIds.Add(projectId);
        // This flag will include all the file system entries I added
        // above, and any items they reference.
        importConfig.IncludeReferencedItems = true;
        // Get the transfer service.
        ITransferService transferService =
        Engine.Current.GetService<ITransferService>();
        // Call the export method of the transfer service.
        TransferResult result = transferService.Import(importConfig);
        if (result.Status == TransferItemResultStatus.Success)
        {
            Console.WriteLine("Success");
        }
    }
}
finally
{
    EngineManager.ShutdownEngine();
}

3.2. Exporting in .NET

When exporting, start the Dundas BI Engine, and log on with a user account that has administrator privileges. The Export method of the ITransferService is used to export objects in .NET. This method takes a ExportConfig object.

The following example demonstrates how to start the Dundas BI Engine, and export a project with the specified ID, and save it to C:\Temp\Project.dbie.

using Dundas.BI;
using Dundas.BI.AccountServices
using Dundas.BI.Services;
using Dundas.BI.Transfer;
using Dundas.BI.FileSystem;
using System.Collections.ObjectModel;
using System.IO;
   ...

try
{
    MultithreadedCallerContextService callerContextService = new MultithreadedCallerContextService();
    // Create the CreateEngineOptions object.
    CreateEngineOptions createEngineOptions = new CreateEngineOptions();
    // Path to the application's data folder.
    CreateEngineOptions.AppDataPath = appDataPath;
    // Connection string for the application database.
    CreateEngineOptions.AppDbConnectionString = appDbConnectionString;
    // The caller context service.
    CreateEngineOptions.CallerContextService = callerContextService;
    // Unique identifier for the engine instance.
    CreateEngineOptions.HostIdentifier = "CreateExportFiles";

    EngineManager.CreateEngine(createEngineOptions);

    // Start the engine.
    EngineManager.StartEngine();

    // Set the current session ID as null.
    using (Engine.Current.GetService<ICallerContextService>().CreateAndSetCurrentContext(null))
    {
        LogOnResult logOnResult = Engine.Current.GetService<ILogOnService>().LogOn(
            // The account name. Type: String
            "admin",
            // The password. Type: String
            "1234",
            // Delete other sessions for the logon to succeed. Type: Boolean
            true,
            // Culture to associate with the session, or null. Type: CultureInfo
            null
        );
	
        // Set the new logon session ID to use.
        Engine.Current.GetService<ICallerContextService>().CurrentContext.SetCurrentSessionId(
            logOnResult.Session.Id
        );
	
        // The ID of the project to export.
        Guid projectId = new Guid("3cc17f9d-b796-45da-a799-c529ea636401");
        // Create an export configuration file.
        ExportConfig exportConfiguration = new ExportConfig();
        // Add the ID of project you would like to export.
        exportConfiguration.FileSystemEntryIds.Add(projectId);
        // This flag will include all the file system entries I added
        // above, and any items they reference.
        exportConfiguration.IncludeReferencedItems = true;
        // Get the transfer service.
        ITransferService transferService = Engine.Current.GetService<ITransferService>();
        // Call the export method of the transfer service.
        TransferResult result = transferService.Export(exportConfiguration);
	
        // Create a file path to save the file to.
        string filePath = @"C:\Temp\Project.dbie";
	
        // Delete the file if it already exists.
        if (File.Exists(filePath))
        {
            File.SetAttributes(filePath, FileAttributes.Normal);
            File.Delete(filePath);
        }
	
        // Write the export to a file.
        using (FileStream output = new FileStream(filePath, FileMode.CreateNew))
        {
            transferService.RetrieveTransferFile(result.TransferFileId).CopyTo(output);
        }
    }
}
finally
{
    EngineManager.ShutdownEngine();
}

4. Using REST Services

Importing and exporting using REST services is accomplished by using the Transfer controller. The two requests that are used for this are:

The samples in the section below were developed using the REST API. For more information on this API, click here.

Note
These examples pass the session ID in an authorization header, which requires version 10 or higher. In earlier versions, you can pass it as a query string parameter in the URL: "...?sessionId=" + sessionId

4.1. Importing using REST Services

This example will log on and import the file C:\Temp\SomeExportFile.dbie with the project ID bd767e1f-1fd2-4411-8b70-af9fdfd763e3.

using System.Net;
using System.Net.Http;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Json;
using System.Web.Script.Serialization;
   ...
using (HttpClient httpClient = new HttpClient())
{
    // Get Session Id
    string logonUri = "http://localhost:8004/Api/LogOn/";
    var logonOptions = new
    {
        accountName = "admin",
        password = "1234",
        cultureName = string.Empty,
        deleteOtherSessions = true,
        isWindowsLogOn = false
    };
    JavaScriptSerializer serializer = new JavaScriptSerializer();
    var requestBodyAsString = serializer.Serialize(logonOptions);
    StringContent content = new StringContent(
        requestBodyAsString,
        Encoding.UTF8,
        "application/json"
    );
    string jsonString = string.Empty;
    using (var response = httpClient.PostAsync(logonUri, content).Result)
    {
        jsonString = response.Content.ReadAsStringAsync().Result;
    }
    var obj = (Dictionary<string,object>)serializer.DeserializeObject(jsonString);
    string sessionId = obj["sessionId"].ToString();
    string url = "http://localhost:8004/API/Transfer/Import/";

    // Add an Authorization header (v10 and higher)
    httpClient.DefaultRequestHeaders.Authorization = 
        new AuthenticationHeaderValue("Bearer", sessionId);

    // Define the request body
    HttpContent requestBody = null;
    requestBody = new StringContent(@" 
        {
            ""importConfiguration"": {
                ""transferFileUncPath"":  ""C:\\\\Temp\\\\SomeExportFile.dbie"",
                ""importEntityTransferVersionPolicy"":  ""CurrentVersionOnly"",
                ""groupMembershipTransferPolicy"":  ""DoNotImport"",
                ""includeReferencedItems"":  true,
                ""includeCustomAttributes"":  true,
                ""includeTokens"":  true,
                ""fileSystemEntryIds"":  [
                    ""bd767e1f-1fd2-4411-8b70-af9fdfd763e3""
                ],
                ""__classType"": ""dundas.transfer.ImportConfig""
            },
            ""includeSubentriesInResultDetails"":  true
        }",
        Encoding.UTF8,
        "application/json"
    );
    using (var response = httpClient.PostAsync(url, requestBody).Result)
    {
        if (response.StatusCode == HttpStatusCode.OK)
        {
            Console.WriteLine("Success");
            //HTTP Status code as well as a <b>Dundas.BI.WebApi.Models.TransferResultData</b> 
            //object or a error message.
            string jsonObject = response.Content.ReadAsStringAsync().Result;
        }
    }
}
    
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpDelete;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPut;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.util.EntityUtils;
import org.apache.http.entity.StringEntity;
import org.json.JSONObject;
   ...
HttpClient httpClient = HttpClientBuilder.create().build();
String url = "http://localhost:8004";
// Get Session Id
String logonUri = url + "Api/LogOn/"
HttpPost httpPost = new HttpPost(logonUri);                    
StringEntity stringEntity = new StringEntity(
    "{\"accountName\":\"admin\","
	    + "\"password":\"1234\","
	    + "\"cultureName\":\"\","
	    + "\"deleteOtherSessions\":false,"
	    + "\"isWindowsLogOn\":false}"
);
stringEntity.setContentType("application/json");
httpPost.setEntity(stringEntity);
HttpResponse httpResponse = httpClient.execute(httpPost);
String jsonString = EntityUtils.toString(httpResponse.getEntity());
JSONObject jsonObj = new JSONObject(jsonString);
String sessionId = jsonObj.getString("sessionId")
String requestUrl = "http://localhost:8004/API/Transfer/Import/";
// Define the Request Method.
HttpPost requstMethod = new HttpPost(requestUrl);
// Add an Authorization header (v10 and higher)
requstMethod.setHeader("Authorization", "Bearer " + sessionId);
// Define the Request Body.
StringEntity input = new StringEntity(
          "{"
        + " \"importConfiguration\":  {"
        + "     \"transferFileUncPath\":  \"C:\\\\Temp\\\\SomeExportFile.dbie\","
        + "    \"importEntityTransferVersionPolicy\":  \"CurrentVersionOnly\","
        + "    \"groupMembershipTransferPolicy\":  \"DoNotImport\","
        + "    \"includeReferencedItems\":  true,"
        + "    \"includeCustomAttributes\":  true,"
        + "    \"includeTokens\":  true,"
        + "    \"fileSystemEntryIds\":  ["
        + "         \"bd767e1f-1fd2-4411-8b70-af9fdfd763e3\" "
        + "    ],"
        + "    \"__classType\":  \"dundas.transfer.ImportConfig\""
        + "},"
        + " \"includeSubentriesInResultDetails\":  true "
        + "}"
);
input.setContentType("application/json");
requstMethod.setEntity(input);
HttpResponse response = httpClient.execute(requstMethod);
if (response.getStatusLine().getStatusCode() == 200)
{
    System.out.println("Success");
}
//HTTP Status code as well as a <b>Dundas.BI.WebApi.Models.TransferResultData</b> 
// object or a error message.
String json = EntityUtils.toString(response.getEntity());
var logonOptions =
{
    accountName: 'admin',
    password: '1234',
    cultureName: 'en-us',
    deleteOtherSessions: false,
    isWindowsLogOn: false
};
$.ajax({
    type: 'POST',
    url: 'http://localhost:8005/Api/LogOn/',
    contentType: "application/json",
    data: JSON.stringify(logonOptions),
    success: function (logOnResultData) {
        var sessionId = logOnResultData.sessionId;
        var dataObject = 
            {          
                 "importConfiguration":  {
                     "transferFileUncPath":  "C:\\\\Temp\\\\SomeExportFile.dbie",
                    "importEntityTransferVersionPolicy":  "CurrentVersionOnly",
                    "groupMembershipTransferPolicy":  "DoNotImport",
                    "includeReferencedItems":  true,
                    "includeCustomAttributes":  true,
                    "includeTokens":  true,
                    "fileSystemEntryIds":  [
                         "bd767e1f-1fd2-4411-8b70-af9fdfd763e3"
                    ],
                    "__classType":  "dundas.transfer.ImportConfig"
                },
                 "includeSubentriesInResultDetails":  true
             
            };
        $.ajax({
            type: "POST",
            url: "/API/Transfer/Import/",
            data: JSON.stringify(dataObject),
            contentType: "application/json",
            headers: { "Authorization": "Bearer " + sessionId },
            success: function (data) {
                // data = HTTP Status code as well as a 
                // <b>Dundas.BI.WebApi.Models.TransferResultData</b> 
                // object or a error message.
            },
            error: function (data) { alert('failed' + data); }
        });
});

4.2. Uploading file and importing using REST Services

This example will log on and upload the file C:\Temp\SomeExportFile.dbie, then import the file with its transferFileId with the project ID bd767e1f-1fd2-4411-8b70-af9fdfd763e3.

This sample uses an additional REST call to upload the file:

using System.Net;
using System.Net.Http;
using System.Runtime.Serialization;
using System.Web.Script.Serialization;
   ...


using (HttpClient httpClient = new HttpClient())
{
    // Get Session Id
    string logonUri = "http://localhost:8000/Api/LogOn/";
    var logonOptions = new
    {
        accountName = "admin",
        password = "1234",
        cultureName = string.Empty,
        deleteOtherSessions = true,
        isWindowsLogOn = false
    };

    JavaScriptSerializer serializer = new JavaScriptSerializer();
    var requestBodyAsString = serializer.Serialize(logonOptions);

    StringContent content = new StringContent(
        requestBodyAsString,
        Encoding.UTF8,
        "application/json"
    );

    string jsonString = string.Empty;

    using (var response = httpClient.PostAsync(logonUri, content).Result)
    {
        Console.WriteLine("LogOn - Success");
	
        jsonString = response.Content.ReadAsStringAsync().Result;
    }


    // ************************************************************************
    // Upload the transfer file.
    // ************************************************************************
    var obj = (Dictionary<string, object>)serializer.DeserializeObject(jsonString);
    string sessionId = obj["sessionId"].ToString();
    string url = "http://localhost:8000/api/transfer/file/";

    // Add an Authorization header (v10 and higher)
    httpClient.DefaultRequestHeaders.Authorization = 
        new AuthenticationHeaderValue("Bearer", sessionId);

    var multiPartRequestBody = new System.Net.Http.MultipartFormDataContent();
    multiPartRequestBody.Headers.ContentType.MediaType = "multipart/form-data";

    string filePath = @"C:\Temp\SomeExportFile.dbie";
    string fileName = new FileInfo(filePath).Name;

    Guid[] transferFileIds = null;

    using (Stream fileStream = System.IO.File.OpenRead(filePath))
    {
        using (StreamContent streamContent = new StreamContent(fileStream))
        {
            multiPartRequestBody.Add(streamContent, fileName, fileName);

            using (var response = httpClient.PostAsync(url, multiPartRequestBody).Result)
            {
                if (response.StatusCode == HttpStatusCode.OK)
                {
                    Console.WriteLine("Upload the transfer file - Success");

                    // An array of Guids.
                    string jsonObject = response.Content.ReadAsStringAsync().Result;
				
                    transferFileIds = (Guid[])serializer.Deserialize(jsonObject, typeof(Guid[]));
                }
            }
        }
    }

    string transferFileId = transferFileIds.First().ToString();

    // ************************************************************************
    // Import the transfer
    // ************************************************************************
    url = "http://localhost:8000/API/Transfer/Import/";
    // Define the request body
    HttpContent requestBody = null;
    requestBody = new StringContent(@"
        {
            ""importConfiguration"":
            {
                ""includeTokens"":false,
                ""__classType"":""dundas.transfer.ImportConfig"",
                ""transferFileUncPath"":"""",
                ""transferFileId"":""" + transferFileId + @""",
                ""source"":""InternalStorageId"",
                ""importEntityTransferVersionPolicy"":""CurrentVersionOnly"",
                ""groupMembershipTransferPolicy"":""DoNotImport"",
                ""includeUserProjects"":true,
                ""includeReferencedItems"":true,
                ""includeCustomAttributes"":false,
                ""accountIds"":[],
                ""groupIds"":[],
                ""tenantIds"":[],
                ""customAttributeIds"":[],
                ""fileSystemEntryIds"":[""bd767e1f-1fd2-4411-8b70-af9fdfd763e3""],
                ""appSettingTransferSpecs"":[],
                ""includeCubeData"":false,
                ""includeContextualData"":false,
                ""includeResourceData"":true,
                ""overwriteDataConnectorSettings"":false
            },
	    ""includeSubentriesInResultDetails"":false
        }",
        Encoding.UTF8,
        "application/json"
    );

    using (var response = httpClient.PostAsync(url, requestBody).Result)
    {
        if (response.StatusCode == HttpStatusCode.OK)
        {
            Console.WriteLine("Import the transfer - Success");
            //HTTP Status code as well as a <b>Dundas.BI.WebApi.Models.TransferResultData</b>
            //object or a error message.
            string jsonObject = response.Content.ReadAsStringAsync().Result;
        }
    }
}

4.3. Export using REST Services

This example will log on and create a transfer export for the project with ID 32bd85be-8980-4153-8919-746990220ab4.

using System.Net;
using System.Net.Http;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Json;
using System.Web.Script.Serialization;
 
   ...
 
using (HttpClient httpClient = new HttpClient())
{
    // Get Session Id
    string logonUri = "http://localhost:8004/Api/LogOn/";
    var logonOptions = new
    {
        accountName = "admin",
        password = "1234",
        cultureName = string.Empty,
        deleteOtherSessions = true,
        isWindowsLogOn = false
    };
 
    JavaScriptSerializer serializer = new JavaScriptSerializer();
    var requestBodyAsString = serializer.Serialize(logonOptions);
    StringContent content = new StringContent(
        requestBodyAsString,
        Encoding.UTF8,
        "application/json"
    );
 
    string jsonString = string.Empty;
 
    using (var response = httpClient.PostAsync(logonUri, content).Result)
    {
        jsonString = response.Content.ReadAsStringAsync().Result;
    }
 
    var obj = (Dictionary<string,object>)serializer.DeserializeObject(jsonString);
    string sessionId = obj["sessionId"].ToString();
    string url = "http://localhost:8004/API/Transfer/Export/";
 
    // Add an Authorization header (v10 and higher)
    httpClient.DefaultRequestHeaders.Authorization = 
        new AuthenticationHeaderValue("Bearer", sessionId);

    // Define the request body
    HttpContent requestBody = null;
    requestBody = new StringContent(@"
        {
            ""exportConfiguration"":  {
                ""name"": ""Export Configuration 20160224_1250"",
                ""entityTransferVersionPolicy"": ""CurrentVersionOnly"",
                ""includeReferencedItems"": true,
                ""includeAllAccounts"": false,
                ""includeAllGroups"": false,
                ""includeGroupMemberships"": false,
                ""includeCustomAttributes"": false,
                ""includeTokens"": false,
                ""accountIds"": [
                     
                ],
                ""groupIds"": [
                     
                ],
                ""fileSystemEntryIds"": [
                    ""32bd85be-8980-4153-8919-746990220ab4""
                ]
            },
            ""includeSubentriesInResultDetails"":  true
        }",
        Encoding.UTF8,
        "application/json"
    );
    using (var response = httpClient.PostAsync(url, requestBody).Result)
    {
        if (response.StatusCode == HttpStatusCode.OK)
        {
            Console.WriteLine("Success");
 
            //A status code indicating success and 
            //<b>Dundas.BI.WebApi.Models.TransferResultData</b> 
            //object or failure and the reason for the failure.
            string jsonObject = response.Content.ReadAsStringAsync().Result;
        }
    }
}
    
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpDelete;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPut;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.util.EntityUtils;
import org.apache.http.entity.StringEntity;
import org.json.JSONObject;
 
   ...
 
HttpClient httpClient = HttpClientBuilder.create().build();
 
String url = "http://localhost:8004";
 
// Get Session Id
String logonUri = url + "Api/LogOn/"
HttpPost httpPost = new HttpPost(logonUri);
StringEntity stringEntity = new StringEntity(
        "{\"accountName\":\"admin\","
	    + "\"password":\"1234\","
	    + "\"cultureName\":\"\","
	    + "\"deleteOtherSessions\":false,"
	    + "\"isWindowsLogOn\":false}"
);
stringEntity.setContentType("application/json");
httpPost.setEntity(stringEntity);
HttpResponse httpResponse = httpClient.execute(httpPost);
String jsonString = EntityUtils.toString(httpResponse.getEntity());
JSONObject jsonObj = new JSONObject(jsonString);
String sessionId = jsonObj.getString("sessionId")
 
String requestUrl = "http://localhost:8004/API/Transfer/Export/";
 
// Define the Request Method.
HttpPost requstMethod = new HttpPost(requestUrl);
 
// Add an Authorization header (v10 and higher)
requstMethod.setHeader("Authorization", "Bearer " + sessionId);

// Define the Request Body.
StringEntity input = new StringEntity(
       "{"
        + " \"exportConfiguration\":  {"
        + "     \"name\": \"Export Configuration 20160224_1250\","
        + "    \"entityTransferVersionPolicy\": \"CurrentVersionOnly\","
        + "    \"includeReferencedItems\": true,"
        + "    \"includeAllAccounts\": false,"
        + "    \"includeAllGroups\": false,"
        + "    \"includeGroupMemberships\": false,"
        + "    \"includeCustomAttributes\": false,"
        + "    \"includeTokens\": false,"
        + "    \"accountIds\": ["
        + "        "
        + "    ],"
        + "    \"groupIds\": ["
        + "        "
        + "    ],"
        + "    \"fileSystemEntryIds\": ["
        + "        \"32bd85be-8980-4153-8919-746990220ab4\""
        + "    ]"
        + "},"
        + " \"includeSubentriesInResultDetails\":  true "
        + "}"
);
input.setContentType("application/json");
requstMethod.setEntity(input);
HttpResponse response = httpClient.execute(requstMethod);
 
if (response.getStatusLine().getStatusCode() == 200)
{
    System.out.println("Success");
}
 
//A status code indicating success and <b>Dundas.BI.WebApi.Models.TransferResultData</b> 
//object or failure and the reason for the failure.
String json = EntityUtils.toString(response.getEntity());
var logonOptions = {
    accountName: 'admin',
    password: '1234',
    cultureName: 'en-us',
    deleteOtherSessions: false,
    isWindowsLogOn: false
};
$.ajax({
    type: 'POST',
    url: 'http://localhost:8005/Api/LogOn/',
    contentType: "application/json",
    data: JSON.stringify(logonOptions),
    success: function (logOnResultData) {
        var sessionId = logOnResultData.sessionId;
        var dataObject = {
            "exportConfiguration": {
                "name": "Export Configuration 20160224_1250",
                "entityTransferVersionPolicy": "CurrentVersionOnly",
                "includeReferencedItems": true,
                "includeAllAccounts": false,
                "includeAllGroups": false,
                "includeGroupMemberships": false,
                "includeCustomAttributes": false,
                "includeTokens": false,
                "accountIds": [
                         
                ],
                "groupIds": [
                         
                ],
                "fileSystemEntryIds": [
                    "32bd85be-8980-4153-8919-746990220ab4"
                ]
            },
            "includeSubentriesInResultDetails":  true
        };
 
        $.ajax({
            type: "POST",
            url: "/API/Transfer/Export/",
            data: JSON.stringify(dataObject),
            contentType: "application/json",
            headers: { "Authorization": "Bearer " + sessionId },
            success: function (data) {
                // data = A status code indicating success and 
                // <b>Dundas.BI.WebApi.Models.TransferResultData</b> 
                // object or failure and the reason for the failure.
            },
            error: function (data) { alert('failed' + data); }
        });
});

5. Using the JavaScript API

To import or export using the JavaScript API, you will need to write the code in an event provided by the user interface, or inside of a custom extension that provides a mechanism for running script. For more information on this API, click here.

5.1. Importing in JavaScript

The following script imports a project from \\MySharedFolder\ShareFolder\ExportShares\Dummy.dbie into the application.

Note
This script was designed to run from a dashboard, and requires the executing session to be for an administrator user.

// Get the transfer service.
var transferService = this.getService("TransferService");
var importConfig = new dundas.transfer.ImportConfig({
    transferFileUncPath: "\\\\MySharedFolder\\ShareFolder\\ExportShares\\Dummy.dbie",
    importEntityTransferVersionPolicy: 
       dundas.transfer.EntityTransferVersionPolicy.CURRENT_VERSION_ONLY,
    groupMembershipTransferPolicy: dundas.transfer.GroupMembershipTransferPolicy.DO_NOT_IMPORT,
    includeReferencedItems: true,
    includeCustomAttributes: true,
    includeTokens: true,
    fileSystemEntryIds: ["12e00c72-14ab-436c-bccb-7ab56d30e5cc"], // the project ID
    transferFileId: "00000000-0000-0000-0000-000000000000" // empty (unused)
});
var importOptions = {
    importConfiguration: importConfig,
    includeSubentriesInResultDetails: true
};
var importPromise = transferService.import(importOptions);
importPromise.done(function (transferResult) {
    alert(transferResult.status);
});

5.2. Exporting in JavaScript

The following example demonstrates how to export a project, pushing a file to the browser using the JavaScript API.

Note
This script was designed to run from a dashboard, and requires the executing session to be for an administrator user.

// Get the transfer service.
var transferService = this.getService("TransferService");
// Get the web app service.
var webAppService = this.getService('WebAppService');
// The export config.
var exportConfig = new dundas.transfer.ExportConfig({
    "name": "Export Configuration " + new Date().toString(),
    "entityTransferVersionPolicy": "CurrentVersionOnly",
    "includeReferencedItems": true,
    "includeAllAccounts": false,
    "includeAllGroups": false,
    "includeGroupMemberships": false,
    "includeCustomAttributes": false,
    "includeTokens": false,
    "accountIds": [],
    "groupIds": [],
    "fileSystemEntryIds": ["899f8f4f-aa2c-46aa-8a68-bac2c8ab367e"] // The project ID
});
var exportOptions = {
    exportConfiguration: exportConfig,
    includeSubentriesInResultDetails: true
}

var exportPromise = transferService.export(exportOptions);
exportPromise.done(function (transferResult) {
    var downloadUrl = transferService.getTransferFileUrl(transferResult.transferFileId);
    
    // Force the browser to download the file.  
    window.location.replace(downloadUrl);
});

6. See also

Dundas Data Visualization, Inc.
400-15 Gervais Drive
Toronto, ON, Canada
M3C 1Y8

North America: 1.800.463.1492
International: 1.416.467.5100

Dundas Support Hours:
Phone: 9am-6pm, ET, Mon-Fri
Email: 7am-6pm, ET, Mon-Fri