Import

Description

'Import' endpoint is used to import already exported zip file to the Controller. This endpoint can be used to move flows from one controller another. Note that, target item with 'targetItemId' must be a folder.

Request URL

http://{controllerMachine}:{controllerPort}/api/v3/import/{timeoutMinutes}/{targetItemId}

Input parameters

Field Type Description Comments
timeoutMinutes integer Maximum timeout for upload  
targetItemId string Unique identifier for Item in the Asset hierarchy Item can be 'Folder', 'Flow', 'DataFile', 'SubFlow', 'InteractiveImage', 
'DesktopElement', 'WebElement', 
'InteractiveImageCollection' etc.
zip file formData File to be imported  

Examples

Curl


curl curl -X POST --header 'Content-Type: multipart/form-data' --header 'Accept: application/json' --header 'accessKey: Mo87Nc4qDAtzJNDb' {"type":"formData"} 'http://{controllerMachine}:{controllerPort}/api/v3/import/30/{targetItemId}'

PowerShell 

$function Import {
    param
    (
        [string]$Path,
        [string]$Hostname,
        [int]$ApiPort,
        [string]$AccessKey,
        [int]$MinutesTimeOut,
        [string]$TargetItemId = ""
    )
    $fileName = [IO.Path]::GetFileName($Path)
    $boundary = [guid]::NewGuid().ToString()
    $fileBytes = [System.IO.File]::ReadAllBytes($Path)
    $fileBody = [System.Text.Encoding]::GetEncoding("iso-8859-1").GetString($fileBytes)
    $LF = "`r`n";
    $headers = @{}
    $headers.Add("AccessKey",$AccessKey)
    $headers.Add("Accept","application/json")
    $url = "http://$Hostname"+":$ApiPort/api/v3/import/$MinutesTimeOut/$TargetItemId"
    $bodyLines = (
    "--$boundary",
    "Content-Disposition: form-data; name=`"zip file`"; filename=`"import.zip`"",
    "Content-Type: application/x-zip-compressed$LF",
    $fileBody,
    "--$boundary--$LF"
) -join $LF
    try{
           Invoke-RestMethod -Uri $url -Method Post -Headers $headers -ContentType "multipart/form-data;              boundary=`"$boundary`"" -Body $bodyLines
        }
    catch
        {
          $ErrorMessage = $_.Exception.Message
          $ErrorMessage
       }
}
$uploadPath="C:\Users\Test\Downloads\All_Assets.zip"
$hostName = "controllerMachine"
$apiPort = controllerPort
$accessKey = "Mo87Nc4qDAtzJNDb"
$timeOut = 10

#Import $uploadPath
Import -Path $uploadPath -Hostname $hostName -ApiPort $apiPort -AccessKey $accessKey -MinutesTimeOut $timeOut

Please note : It is strongly recommended to set timeoutMinutes >> than real export time, even if it is small. If it is <= 0, default value of 3 hours will be set.

Response Body

Below response object 

{
   "$id": "1",
"IsSuccessful": true
}

 

Response Parameters

Field Type Description Values
$id string ID of internal object  
IsSuccessful bool Returns true on successful import else false  


Response Code

200 (OK)

400 (Request type is incorrect)

401 (Incorrect access key)

404 (Folder by targetItemId not found/asset is found but it’s not a folder)

409 (Non-resolvable asset title collision)

 

500 (Internal Server Error)