I am trying to launch my bot after a SQL job has completed and calls a Powershell script. I can get the token, but the syntax on start job is confusing me as I’m not very familiar with PS.
Definitely too late Bala on replying to this one sorry but for all future readers,
The issue was simply how the header was being declared, if you create the dictionary object of string, string first,
$headers1 = New-Object “System.Collections.Generic.Dictionary[[String],[String]]”
Then add the tokens like this, $headers1.Add(“Authorization”, “$token”) | ConvertTo-Json
So a final Powershell rest call may look like,
(Get a token)
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$postBody = @{tenancyName=‘’;usernameOrEmailAddress=‘userName’;password=‘Password’}
$headers = @{ContentType=‘application/json’}
$response = Invoke-WebRequest -Uri https://yoururl/api/account/authenticate -Method POST -Body $postBody -Headers $headers | ConvertFrom-Json;
$token = ('Bearer ’ + $response.result );