I am curious if anyone has connected to the Control Room APIs through PowerShell for A360. I am attempting to assist someone that wants to kick off a taskbot through powershell via the API, but am running into a wall. I can connect easily enough and obtain the token, something like so:
$sUrl = "https://CR_URL/v1/authentication"
$body = @{
'username' = "Username"
'password' = "Password"
}
$bodyJson = $body | ConvertTo-Json
$Response1 = Invoke-RestMethod -Method Post -Uri $sURL -Body $bodyJson
$Response1.token
However, to launch a bot I need to connect to the workspaces and find the bot file ID. To do so I need to add the token from the above step and connect to "https://CR_URL/v2/repository/workspaces/{workspaceType}/files/list". I cannot seem to get the syntax correct for adding the token to the header. I have tried a couple of variations of this:
$newURL = "https://CR_URL/v2/repository/workspaces/private/files/list"
$authVal = $Response1.token
$newBody = @{
#Body for file filter
}
$newBodyJson = $newBody | ConvertTo-Json
$Response2 = Invoke-RestMethod -Method Post -Uri $newURL -Body $newBodyJson -Headers @{"AUTHORIZATION"=$authVal}
I know this is just a syntax error as I can get it to work outside of PS. Was just curious if anyone has an example of making the connection and listing the CR files in PowerShell that I can look at.