- This topic has 2 replies, 2 voices, and was last updated October 26, 2016 by Bob T.
Issue retrieving REST API vpgSettings object
-
Hello,
I’m hoping someone can help me figure out what I’m doing wrong. No matter what I try, I cannot seem to retrieve/create a vpgSettings object. Below are some examples of what I’m trying and failing. I’ve purposely left out all of the connection information due to that all works. I can successfully access VMs, VPGs, localsite, peersite, etc.
First, if I enter the following in a browser:
https://zvm_ip:9669/v1/vpgsettings/help (with the appropriate IP, of course)
I get the following:
Endpoint not found. Please see the service help page for constructing valid requests to the service.
I’ve also tried various “JSON bodies” but receive the error listed below:
URL for all samples:
$vpgsettingsUrl = “https://” + $ZertoServer + “:”+$ZertoPort+”/v1/vpgsettings”
“body” samples:
$JSON =
“{}”$JSON =
“{
“”VpgIdentifier””:””$VPGidentifier””
}”$JSON =
“{
“”VpgIdentifier””:””9db80554-85c7-4cfb-ae0c-5ecf591776a6″”
}”Invoke method for all samples:
$VPGSettingsIdentifier = Invoke-RestMethod -Method Post -Uri $vpgsettingsUrl -Body $JSON -ContentType “application/json” -Headers $zertosessionHeader
Powershell error:
Invoke-RestMethod : Service
Endpoint not found. Please see the service help page for constructing valid requests to the service.
At line:1 char:26
+ $VPGSettingsIdentifier = Invoke-RestMethod -Method Post -Uri $vpgsettingsUrl -Bo …
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommandAny help or guidance would be greatly appreciated!
Thanks,
– Bob
Junichi SOctober 25, 2016 02:17:37 PMHey Bob,
I use:
$baseURL = “https://” + $ZertoServer + “:”+$ZertoPort+”/v1/”
$contentType = “application/json”
$CreateVPGURL = $BaseURL+”vpgSettings”
$JSON =
“{
“”VpgIdentifier””:””$VPGidentifier””
}”
Try
{
$VPGSettingsIdentifier = Invoke-RestMethod -Method Post -Uri $CreateVPGURL -Body $JSON -ContentType $ContentType -Headers $zertosessionHeader
write-host “VPGSettingsIdentifier: $VPGSettingsIdentifier”
$ValidVPGSettingsIdentifier = $true
}
Catch {
Write-Host $_.Exception.ToString()
$error[0] | Format-List -Force
$ValidVPGSettingsIdentifier = $false
}This works for me without problem, but doesn’t seem to be working for you. Can I ask what version of ZVR you are running? It needs to be a 4.5 build as a minimum for this API call to function. Thanks,
Joshua
Hi Joshua,
Thanks very much for your response. Your last line, I believe, is my issue. My ZVR is currently only at v4.0 Update 2. This would explain my issue, and give me a reason to add upgrading my ZVR to my list.
Thanks again,
– Bob
The forum ‘Scripting and APIs’ is closed to new topics and replies.