I am trying to updated the timeout parameter on all step of the web scenarios in a host to a certain value using PowerShell but I am getting an getting the following error
my script is the following
I am not sure where the error is coming from. Any advice? I have checked the data type of $body.params.steps and it look correct.
Code:
jsonrpc : 2.0
error : @{code=-32602; message=Invalid params.; data=Invalid parameter "/1/steps/1": an array is expected.}
id : 1
Code:
$ZabbixServerEndpointUri = "..."
$body = @{
"jsonrpc" = "2.0"
"method" = "httptest.get"
"params" = @{
"filter"= @{
"httptestid"= 382
}
"selectSteps" = "extend"
"output" = "extend"
}
"auth" = ""
"id" = 1
}
$JSON_reponse = Invoke-RestMethod -Uri $ZabbixServerEndpointUri -Body ($body | ConvertTo-json) -method POST -ContentType "application/json"
$body = @{
"jsonrpc" = "2.0"
"method" = "httptest.update"
"params" = @{
"httptestid" = $JSON_reponse.result.httptestid
"steps" = @()
}
"auth" = "..."
"id" = 1
}
$body.params.steps = [array]@($JSON_reponse.result.steps | foreach-object {$_.timeout ="5s";$_})
$JSON_result = Invoke-RestMethod -Uri $ZabbixServerEndpointUri -Body ($body2 | ConvertTo-json) -method POST -ContentType "application/json"
$JSON_result