In the previous articles, we focused on MOVEit Automation's REST API, but it’s now time to focus on MOVEit Transfer.
To get started with MOVEit Transfer’s API, we’ll again have to grab an access token. We’ll then use this access token throughout all of the API calls we make to the MOVEit Transfer API. The process is the same as MOVEit Automation. The only difference is the URL endpoint to connect to.
Below is the PowerShell code you can use to get a token.
$hostName = 'MyMoveITTransferServer'
$authEndpointUrl = "https://$hostName/api/v1/token"
$authHttpBody = @{
grant_type = 'password'
username = 'myuser'
password = 'mypassword'
}
[System.Net.ServicePointManager]::ServerCertificateValidationCallback = { $true }
$token = Invoke-RestMethod -Uri $authEndpointUrl -Method 'POST' -Body $authHttpBody
$token = $token.access_token
Related: Using The New MOVEit 2018 REST API With PowerShell
Once you’ve got the token, it’s now time to create the new user. The most important part of this task and with all API operations using the MOVEit REST API is to get the JSON body you’ll be sending to the API correctly. The JSON body is the main component of the call and is used to store all of the attributes of the user being created. To create a new user, we first need to create a text file in JSON representing the user attributes. Below is an example.
JSON { "fullName": "Adam Bertram", "username": "abertam", "password": "passwordhere12", "email": "adam@adamtheautomator.com", "permission": "User", "mustChangePassword": true, "notes": "Coolest automator ever!", "homeFolderPath": "/home/abertram", "homeFolderInUseOption": "AllowIfExists" }
I’m going to assume this JSON file path is at C:.json on your local computer. Once you’ve got the JSON file created, it’s then time to gather up all of the parameters you’ll be passing to the Invoke-RestMethod command in PowerShell. Since we covered these parameters in previous articles, I’ll just document them here.
The parameters can be stored in a hashtable.
$newUserParams = @{
Uri = 'https://<moveittransferservername>/api/v1/users'
Headers = @{ 'Authorization' = "Bearer $token" }
Method = 'POST'
Body = (Get-Content -Raw -Path 'C:\DemoUser.json')
ContentType = 'application/json'
}
Once all of the parameters have been defined, we can then pass them all to Invoke-RestMethod at once using splatting.
PS> Invoke-RestMethod @newUserParams
emailFormat : HTML
notes : Coolest automator ever!
statusNote :
passwordChangeStamp : 2018-03-17T13:26:02
receivesNotification : ReceivesNotifications
forceChangePassword : False
folderQuota : 0
authMethod : MOVEitOnly
language : en
homeFolderID : 464845759
defaultFolderID : 464845759
expirationPolicyID : 0
id : ua26iyn8v6q49l8g
orgID : 7797
username : abertam
realname : abertam
permission : User
email : adam@adamtheautomator.com
status : Active
lastLoginStamp : 0001-01-01T00:00:00
If you receive an output like above, that means it was successful. To confirm, log into the MoveIT Transfer web interface, and you should see the user created!
Adam Bertram is a 20-year veteran of IT. He’s currently an automation engineer, blogger, independent consultant, freelance writer, author, and trainer. Adam focuses on DevOps, system management, and automation technologies as well as various cloud platforms. He is a Microsoft Cloud and Datacenter Management MVP and efficiency nerd that enjoys teaching others a better way to leverage automation.
Let our experts teach you how to use Sitefinity's best-in-class features to deliver compelling digital experiences.
Learn MoreSubscribe to get all the news, info and tutorials you need to build better business apps and sites
Progress collects the Personal Information set out in our Privacy Policy and the Supplemental Privacy notice for residents of California and other US States and uses it for the purposes stated in that policy.
You can also ask us not to share your Personal Information to third parties here: Do Not Sell or Share My Info
We see that you have already chosen to receive marketing materials from us. If you wish to change this at any time you may do so by clicking here.
Thank you for your continued interest in Progress. Based on either your previous activity on our websites or our ongoing relationship, we will keep you updated on our products, solutions, services, company news and events. If you decide that you want to be removed from our mailing lists at any time, you can change your contact preferences by clicking here.