• This topic has 5 replies, 3 voices, and was last updated February 7, 2018 by Nina D.

"Setting Validation Failed" in Invoke-RestMethod

  • I am using a script to pull the settings of all VM NIC settings, based off the script found here starting on page 16:

    https://www.zrto-dev.com/wp-content/uploads/2016/09/Automating-Zerto-Virtual-Replication-with-PowerShell-and-REST-APIs.pdf

    It mostly works, however I found it was skipping over some VPGs. Digging into it, I found that the problem was occuring here (near the top of page 18):

    <h6>##########################################
    # Posting the VPG JSON Request to the API
    ################################################
    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
    }</h6>

    What’s going on is for a specific few VPGs, when I call

    $VPGSettingsIdentifier = Invoke-RestMethod -Method Post -Uri $CreateVPGURL -Body $JSON -ContentType $ContentType -Headers $zertosessionHeader

    It returns an error.  The error reads:

    Invoke-RestMethod : {“Message”:”Setting validation failed: Below fileds Warning Journal Percent[ Profile value

    35 , New Value 0 ] , Hard Limit Journal Percent[ Profile value 45 , New Value 0 ] are not corresponds service

    profile definitions; “}

    At line:1 char:26

    + $VPGSettingsIdentifier = Invoke-RestMethod -Method Post -Uri $CreateVPGURL -Body …

    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod]

    , WebException

    + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodComm

    and

     

    So what does this imply?  I’m guessing some of the VPG settings are saved in some invalid way (I notice it specifically talks about the journal limits) which is causing the settings ID to be messed up, but the VPG appears to be functioning normally otherwise. Barring recreating the VPG, any idea what I can do to fix it or at least figure out in more detail what’s wrong?

     

    Thanks!

    Hi Nina,

    I am by no means a scripter, but the issue may be due to a change in our script headers.  The $zertosessionHeader is no longer valid depending on the version of ZVR you are using.  You now need to specify the content type in the header (xml or json).

    All that being said, I will bring this up with one of the tech evangelists because he is a much more proficient scripter.

    Thanks!

    Thanks Ryan,

    The header issue you mentioned is indeed something we had to deal with, though my original post may have had some conflicting information with the code as I was copying it from the Zerto document but our code had already taken the changes into account.  The exact code I’m running is:

    ################################################

    # Starting for each VPG action of collecting ZVM VPG data

    ################################################

    foreach ($VPGLine in $zertoprotectiongrouparray)

    {

    $VPGidentifier = $VPGLine.vpgidentifier

    $VPGOrganization = $VPGLine.OrganizationName

    $VPGVMCount = $VPGLine.VmsCount

    $JSON =

    “{

    “”VpgIdentifier””:””$VPGidentifier“”

    }”

    ################################################

    # Posting the VPG JSON Request to the API

    ################################################

    Try

    {

    $VPGSettingsIdentifier = Invoke-RestMethod -Method Post -Uri $CreateVPGURL -Body $JSON -ContentType $TypeJSON -Headers $zertoSessionHeader_json

    $ValidVPGSettingsIdentifier = $true

    }

    Catch {

    $ValidVPGSettingsIdentifier = $false

    }

     

    And to note this works for most of our VPGs, just a select few we’ve found so far that return the error I listed above.

    Thanks!

    Ahh, in that case I am afraid I will have to defer to my trust tech evangelist.

    I just emailed him the link to this post so he will respond as soon as he is able to.

    Thank you for the patience!

    Hi Nina!

    Thanks for reaching out. To be able to troubleshoot this I would love to see the full script and maybe also some output from the VPG config itself (at least the VPGs where it fails). Maybe it’s easier to reach out to me directly on gijsbert [at] zerto [dot] com.

    For all the followers of this thread! I’ll make sure we post the solutions and explanation to the forums as soon as we found it :).

    Just as a follow up to this in case anyone in the future needs it –

     

    I worked with Gijsbert a bit and at his suggestion messed around with my service profile and journal configuration settings (in the replication tab of the affected VPGs).  My service profile is set to have a 4 hour history, with the journal limit values at 35%/45%.  When I changed it to a custom profile the problem seemed to go away, even though I matched what my actual service profile had exactly.  When I changed it back, the problem came back.

    So it seems like there was something going on with the service profile – further apparent by the exception that I was getting mentioning it:

    Invoke-RestMethod : {“Message”:”Setting validation failed: Below fileds Warning Journal Percent[ Profile value 35 , New Value 0 ] , Hard Limit Journal Percent[ Profile value 45 , New Value 0 ] are not corresponds service profile definitions; “}

    Notice how it shows the journal values I mentioned (35/45), but then mentions “New Value 0” on both.  I mentioned to Gijsbert that it seems like maybe this is the default value when it can’t actually pull the data, as a journal hard limit of 0% either means unlimited (which we don’t have it set to), or would make recovery virtually impossible if it was actually 0%.

    I’m not sure why it cared about the actual profile or how the profile itself was bad, but we were luckily in the process of moving all our VPGs to a new service profile instead which also fixed the problem VPGs as we changed them.

    If it’s not private, I’d love to see the actual code for the API so I can see where it defines that exception to throw and maybe run through it to see where the check failed for me.

    Thanks Gijsbert for putting me in the right direction and helping me figure out it was a problem with the recovery service profile. 🙂

You must be logged in to create new topics. Click here to login