Not sure where this post should go, but I'm trying to make a basic REST call to vROps and start with getting a token and can't.
Here's my code:
$mybody = @{
username = "admin"
password = "my password"
}
$json = $mybody| ConvertTo-Json
$response = Invoke- RestMethod -uri https://192.168.1.60/api/auth/token/acquire -Method Post -Body $json -ContentType 'application/json'
I'm getting this response:
Invoke-RestMethod : The remote server returned an error: (404) Not Found.
At C:\powershell\vrops-rest.ps1:6 char:13
+ $response = Invoke-RestMethod -uri https://192.168.1.60/api/auth/token/acquire -
...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWeb
Request) [Invoke-RestMethod], WebException
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.C
ommands.InvokeRestMethodCommand
I can ping vROps fine at this IP and can view the rest API at https://192.168.1.60/suite-api/docs/rest/index.html just fine.
Any ideas?
Thanks!
Is there a specific reason why you want to do the REST calls directly like this?
There is a module available for vROPs API, see Getting started with PowerCLI for vRealize Operations (vR OPs) and Using the entire API for vRealize Operations via PowerCLI
In your Invoke-RestMethod call it looks like the used Uri might not be correct.
Have a look at vRops API consumed with Powershell
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Is there a specific reason why you want to do the REST calls directly like this?
There is a module available for vROPs API, see Getting started with PowerCLI for vRealize Operations (vR OPs) and Using the entire API for vRealize Operations via PowerCLI
In your Invoke-RestMethod call it looks like the used Uri might not be correct.
Have a look at vRops API consumed with Powershell
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
My understanding was that with vROPs, if you are going to do things with powercli, then you only have a limited set of the vROPs functionality available to you, whereas in fact all of the functionality is available through the APIs if you are willing to use native powershell and rest calls. Is that incorrect or has that changed on vROps 6.4?
Thanks!
That is correct, but as the 2nd post shows, you use the PowerCLI cmdlets to set up the connection.
And from there you have access to the complete vROPs API.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference