Im are trying to create an series of new jobs, through the new RestAPI in V11.
I got the authorization part figured out, and are able to pull job settings, start jobs, etc - but i cant seem to find a way, to create an new job properly.
This is my code so far:
Code: Select all
$GlobalHeaders = @{
'x-api-version' = '1.0-rev1'
'Authorization' = "Bearer $accesstoken"
}
$JobNameBody = @{
"name" = $NewTagName
"description" = "Backup Job"
"type" = "Backup"
"isHighPriority" = $false
"virtualMachines.includes.hostname" = "vcenter.domain.com"
"virtualMachines.includes.type" = "tag"
"virtualMachines.includes.name" = "Backup_Job1_tag"
"storage.backupRepositoryId" = "1a2872d4-5924-4851-8b65-007336dd142d"
"storage.backupProxies.AutoSelection" = $true
"storage.retentionPolicy.type" = "Days"
"storage.retentionPolicy.quantity" = 14
"guestProcessing.appAwareProcessing.isEnabled" = $true
"guestProcessing.guestFSIndexing.isEnabled" = $true
"schedule.runAutomatically" = $false
} | ConvertTo-Json
Invoke-RestMethod -Method Post -Uri "https://dkvbr:9419/api/v1/jobs" -Headers $GlobalHeaders -ContentType "application/json" -Body $JobNameBody
Code: Select all
Invoke-RestMethod : {"errorCode":"UnknownError","message":"Object reference not set to an instance of an object.","resourceId":null}