Knowledge base
Tips and tricks Best practice guides, FAQ & more
Find tutorials, guides and use case examples in the
Learning centerThe 'Import To Team' endpoint is used to import already exported .zip files to a predefined team on the Controller. This endpoint can be used to move flows from one Controller another. Note that target items with 'targetItemId' must be a folder.
Please note this endpoint will work with the Leapwork Enterprise Edition only.
http://{controllerMachine}:{controllerPort}/api/v4/import/{teamid}/{timeoutMinutes}/{targetItemId}?force=1
Field | Type | Description | Comments |
---|---|---|---|
teamId | string | The teamId is a unique Id for the team defined under the LEAPWORK Enterprise Edition. | teamId can be fetched from the Response Body of Get All Team endpoint |
timeoutMinutes | integer | Maximum timeout for upload | |
targetItemId | string | Unique identifier for an item in the asset hierarchy | The item can be 'Folder', 'Flow', 'DataFile', 'SubFlow', 'InteractiveImage', 'DesktopElement', 'WebElement', 'InteractiveImageCollection' etc. |
zip file | formData | File to be imported | |
Force | string | Force mode locks all user-opened flows which should be replaced during import caused by a title collision | optional parameter |
curl curl -X POST --header 'Content-Type: multipart/form-data' --header 'Accept: application/json' --header 'accessKey: Mo87Nc4qDAtzJNDb' {"type":"formData"} 'http://{controllerMachine}:{controllerPort}/api/v4/import/9fb4ef50-6924-471d-8261-052aa8b572c9/30/{targetItemId}'
function Import {
param
(
[string]$Path,
[string]$Hostname,
[int]$ApiPort,
[string]$AccessKey,
[int]$MinutesTimeOut,
[string]$TargetItemId = "",
[string]$TeamId = ""
)
$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/v4/import/$TeamId/$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
$teamId = ““
#Import $uploadPath
Import -Path $uploadPath -Hostname $hostName -ApiPort $apiPort -AccessKey $accessKey -MinutesTimeOut $timeOut -TeamId $teamId
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.
Below is the response object:
{
"$id": "1",
|
Field | Type | Description | Values |
---|---|---|---|
$id | string | ID of internal object | |
IsSuccessful | bool | Returns true on successful import or 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)
©2024, Leapwork. All rights reserved.