$body = @{
RunbookId = $adminRoleRunbookId
# RunbookId = $runbookId
RunbookServers = @($runbookServer)
Parameters = @(
[pscustomobject]@{Name='Reason';Value='Some text'},
[pscustomobject]@{Name='User';Value='Some user'},
[pscustomobject]@{Name='Version';Value='Some version'}
)
CreatedBy = $null
} | ConvertTo-Json
Orchestrator 2022 passing parameters to runbook with API
Brad Davis
81
Reputation points
Trying to call a runbook on Orchestrator 2022 with Powershell and pass parameters to runbook. I need to pass multiple parameters, but started with just one. It works fine when I remove the parameter from the runbook's Initialize Data and the Powershell API call, but as soon as I add it I get (400) Bad Request. Partial code below (removed some variable declarations for privacy):
$body = @{
RunbookId = "0E3D0830-5BB6-4717-BB94-330E0338F153"
Parameters = @{
"457F99B3-1267-4848-A91B-5F4B746BA1EA" = $Action
}
CreatedBy = $null
} | ConvertTo-Json
Invoke-RestMethod -Uri ('{0}/api/Jobs' -f $OrchURI) -Body $body -Method Post -ContentType 'application/json' -UseDefaultCredentials
1 answer
Sort by: Most helpful
-
Fabien Gaille 0 Reputation points
2023-03-07T12:16:12.21+00:00