I am getting an error message when trying to install an update - can you help me with the request_body, please. I've tried few variants but not sure what I should be using...
$vamiInstallUpdateRawBody = @"
{
"user_data": {
"key": "id",
"value": "$vamiLatestUpdateVer"
}
}
"@
$vamiInstallUpdateRawBody = @"
{
"user_data": {
"key": "vmdir.password",
"value": "$vCenterUserNamePsw"
}
}
"@
$vamiInstallUpdateBody = $vamiInstallUpdateRawBody | ConvertFrom-Json
$vamiUpdateUri = "https://$vCenterAppliance/api/appliance/update/pending/$($vamiLatestUpdateVer)?action=install"
$vamiUpdateAPI = Invoke-WebRequest -Uri $vamiUpdateUri -Method Post -Headers $session -Body $vamiInstallUpdateBody -SkipCertificateCheck
Invoke-WebRequest: {"error_type":"INVALID_ARGUMENT","messages":[{"args":["operation-input","user_data"],"default_message":"Structure operation-input is missing a field \"user_data\"","id":"vapi.data.structure.field.missing"}]}
$vamiLatestUpdateVer is "7.0.3.01700" in my case
You don't specify what you have in
$vamiLatestUpdateVer
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
$vamiLatestUpdateVer holds the version of what needs to be installed, "7.0.3.01700" in this case
I came across this blog post by Michael Voigt (txusa) where an alternative method to trigger the update process is being used, which works just fine. Oddly, the method below accepts "whatever" for user_data 🙂 - I am just curious what I was doing wrong when trying to use Invoke-WebRequest
$cisConnection = Connect-CisServer -server vcenter.txusa.cloud
$getService = Get-CisService -Name "com.vmware.appliance.update.pending"
$user_data = $getService.help.stage_and_install.user_data.Create()
$user_data.add("whatever","whatever")
$getService.stage_and_install($patchVersion,$user_data)
That content for $vamiLatestUpdateVer is incorrect.
That should be a structure as documented in Install Pending under Request Body.
The Key in there can be obtained through a call to List Pending, providing an update was staged with Stage Pending.
Note that there are PowerCLI examples on all these pages in the VAMI API Reference.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference