POST /Transfer/File/

Stores (uploads) the transfer file. This API call expects form files inside the request body.
 

Request

Method Request URI
post /API/Transfer/File/?sessionId=value

URI Parameters

URI Parameter Description
sessionId The current session ID. Specifying via an Authorization request header instead is recommended.

Request Headers

Authorization: Bearer <Current session ID>

Request Body

This API call expects form files inside the request body. This API call only supports MIME multipart content - for more information see: https://www.w3.org/Protocols/rfc1341/7_2_Multipart.html

Response

Response Body

The operation completed successfully. The payload contains an array of System.Guid objects representing the stored file IDs.

Response Codes

Response Code Description
200 The operation completed successfully.
400 The request contained one or more invalid parameters.
403 The caller does not have the necessary privileges for the attempted operation and/or the specified item.
405 The content of the file does not match a transfer file; -or- incorrect content-type.
415 The request payload is not multipart form data.
440 The caller is not associated with a valid session.

Examples

This example will login and upload the file 'C:\Temp\SomeExportFile.dbie' and then will import the file with it's transferFileId with the project ID 'bd767e1f-1fd2-4411-8b70-af9fdfd763e3'.

C#

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/";
 
 
   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))
    {
	    // Add an Authorization header
        httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", sessionId);
 
        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;
    }
     
   }
 
 
}