Ad Widget

Collapse

how to change timeout parameter on steps of web scenarios using the API and PS

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • maco1717
    Junior Member
    • Apr 2019
    • 21

    #1

    how to change timeout parameter on steps of web scenarios using the API and PS

    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
    Code:
    jsonrpc : 2.0
    error : @{code=-32602; message=Invalid params.; data=Invalid parameter "/1/steps/1": an array is expected.}
    id : 1
    my script is the following
    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
    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.
Working...