Solved

RestAPI Get Running VMJobs

  • 22 April 2022
  • 4 replies
  • 258 views

Badge +4

Hello Team

 

I was trying to get the running jobs for a specific VM. I have below code but it is returning zero results. 

 

function Get-CVVMJobStatus {
param (
$VMName
)
$vmGuid = ($Global:CVVMData.vmStatusInfoList | Where-Object name -eq $VMName).strGUID
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("Accept", "application/json")
$headers.Add("Authtoken", $Global:cvToken)
$URI = "http://xxxx/webconsole/api/v2/vsa/vm/$vmGuid/Jobs?completedJobLookupTime=3600&jobTypeList=backup&showAgedJobs=true&backupLevel=Full,Incremental"
$response = Invoke-RestMethod $URI -Method 'GET' -Headers $headers
$JobsData
return $response

}

 

icon

Best answer by Carl Manzi 25 April 2022, 21:34

View original

4 replies

Userlevel 7
Badge +23

Are you getting any errors?

I’m pasting the syntax from the docs for this API:

http://WebConsoleHostName/webconsole/api/v2/vsa/vm/{{vmGuid}}/Jobs?completedJobLookupTime=12960000&jobTypeList=backup&statusList=Completed,Killed&showAgedJobs=true&backupLevel=Full

and the example:

curl --location -g --request GET '{{ServerURL}}/v2/vsa/vm/{{vmGuid}}/Jobs?completedJobLookupTime=12960000&jobTypeList=backup&statusList=Completed,Killed&showAgedJobs=true&backupLevel=Full' \
--header 'Accept: application/json' \
--header 'Authtoken: QSDK token would be auto set after POST Login is called.'

https://api.commvault.com/#c6135933-ef59-46fc-9392-9861875eeb47

Badge +4

Are you getting any errors?

I’m pasting the syntax from the docs for this API:

http://WebConsoleHostName/webconsole/api/v2/vsa/vm/{{vmGuid}}/Jobs?completedJobLookupTime=12960000&jobTypeList=backup&statusList=Completed,Killed&showAgedJobs=true&backupLevel=Full

and the example:

curl --location -g --request GET '{{ServerURL}}/v2/vsa/vm/{{vmGuid}}/Jobs?completedJobLookupTime=12960000&jobTypeList=backup&statusList=Completed,Killed&showAgedJobs=true&backupLevel=Full' \
--header 'Accept: application/json' \
--header 'Authtoken: QSDK token would be auto set after POST Login is called.'

https://api.commvault.com/#c6135933-ef59-46fc-9392-9861875eeb47

No Errors. It displays only Completed or Killed Jobs. Even if I remove statusList filter.


I am looking to trigger bulk backup jobs and get the status of those jobs after submission to check the status on percentageCompleted etc. 

Userlevel 7
Badge +23

@AbdulWajid , I don’t see the statusList in your example text.  Are you saying if you add it, it doesn’t make a difference?

If that’s the case, I would open a support case as it sounds like it isn’t working as expected.

If you can confirm the above and open a case, can you share the incident number here?

Userlevel 4
Badge +8

@AbdulWajid , GET Jobs is for querying the backup history. If you’re looking for jobs that are currently running, I believe you’ll need to use POST Jobs:

https://api.commvault.com/#17736755-e86f-9a27-75c5-6c5e999bec80

Reply