6 Replies Latest reply on Dec 9, 2019 12:23 PM by dtaliafe

    How to get stats from VROPS via REST API

    Panzerbjorn Lurker
      Hi all, we are trying to use REST API via PowerShell to get information from VROPS.
      However, it isn't working, and the documentation isn't particularly helpful, so here I am.

      I can authenticate fine and get a list of the resources I want to get stats for, in the particular case, 3par resources.
      Looking at https://MyvROpsServer/suite-api/docs/rest/index.html, it looks like I need to make a request to https://MyvROpsServer//suite-api/api/resources/{$ResourceID}/stats/query,
      but this gives me a "Invoke-RestMethod : The remote server returned an error: (400) Bad Request." error.

      Here is my code:
      $Headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
      $Headers.Add("Accept", "$Type")
      $Headers.Add("X-vRealizeOps-API-use-unsupported", 'true')
      $Type = "application/xml;charset=utf-8"
      $ResourcesURL = $BaseURL + "resources/$ResourceID/stats/query"
      $Stats = Invoke-RestMethod -Method POST -uri $ResourcesURL -Credential $cred -ContentType $Type -Headers $Headers

      So in short, does anyone know which REST API command would give me the equivalent of PowerCLI's Get-OMStat?
      Or perhaps know of a place that has good examples?
      I have also been trying to format some XML to send in the body, but again, without some useful examples, I haven't been able to get that to work.