One of the exciting new changes in MOVEit Automation 2018 is the expansion of the API to include REST processing. This is in addition to the existing COM and Java methods. It isn’t just a rewrite of the existing API, but includes new functionality that MOVEit Automation users have wanted for some time.
Please note that you must upgrade to MOVEit Automation 2018 and have the API licensed to enjoy the benefits of the REST API.
REST is short for Representational State Transfer – a processing methodology based upon HTTP. Clients initiate requests to the server. Nothing related to the client is stored in between the requests.
In essence, once the client has a URL from its initial connection, it can continue to use that URL in subsequent requests (in a similar way to how COM objects can be reused). Each call must be authorised with the simple passing of a token.
The API makes use of the WebAdmin installation on the Automation server. You will need to install this if you haven’t already (and given that the S3 host is only usable via the webadmin, you should do this anyway). You start with a root URL that you will reference when calling various functions. For example if you are calling the API from on the server you can simply use this (shown in powershell format):
$URI = “https://localhost/webadmin/api/v1”
Note that if using localhost, you will have a certificate error. To avoid this, insert the following line of code into the top of your script:
[System.Net.ServicePointManager]::ServerCertificateValidationCallback = { $true }
Each group of functions adds a new path to the URL, with individual functions grouped beneath the branch. To list the defined hosts, for example, you would use the following:
$hosts = “$URI/hosts”
To start a task you would use:
$start = “$URI/tasks/$taskID/start”
The available paths containing the functions are:
Ipswitch have posted several examples of how to achieve basic tasks on the Customer Portal. These demonstrate how to perform several functions and you can find full documentation for using the API at: https://docs.ipswitch.com/MOVEit/Automation2018/API/REST-API/index.html
Here is a ‘bare bones’ script that stops the scheduler, waits for all tasks to complete, then stops the automation service itself. This is perfect for automating server reboots. This script does not contain error handling, nor is there a limit on how long to wait before giving up on stopping tasks:
$UID = “Myuser”
$PWD = “Mypass”
$URI = “https://myservername.com/webadmin/api/v1”
$token = “$URI/token”
$list = “$URI/tasks/running”
$stop = “$URI/tasks/scheduler/stop”
$authstring = “grant_type=password&username=$UID&password=$PWD”
$auth = Invoke-RestMethod -Uri $token -Method Post -Body $authstring
$mytoken = $auth.access_token
$headers = @{“Authorization” = “Bearer $mytoken”}
“Stopping Scheduler”
Invoke-RestMethod -Uri $stop -Method Put -Headers $headers
“Checking for running Tasks”
$count = 1
while ($count -gt 0) {
$tasks = Invoke-RestMethod -Uri $list -Method Get -Headers $headers
$count = $tasks.items.length
if ($count -gt 0) {
“$count tasks running, sleeping 10 seconds”
sleep 10
}
}
stop-Service Moveitcentral
The MOVEit Automation API module is a separate license. If you don’t currently have it and would like to find out more, get in touch with your account manager or contact us online.