# 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.

### 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

A status code indicating success and an array of stored file IDs, or failure and the reason why.

## 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/?sessionId=" + 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/?sessionId=" + sessionId + "";
       // 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;
        }

       }

    }

© 1999-2021 Dundas Data Visualization, Inc.