Hi @drPhil
There are many ways to invoke REST APIs, the interface is provided so that any such tool can connect to the endpoint to invoke API calls and receive responses over http.
We have several options explained in Commvault, please take a look at:
Getting Started with the Commvault REST API which shows the options we have documented.
But there are many other options available to you:
Microsoft PowerShell Invoke-RestMethod
A quick Google search for “rest api in linux shell” shows where people have used curl:
APIacademy: DevOps: REST API Execution Through Bash Shell Scripting
Thanks,
Stuart
Hi @Stuart Painter , thank you so much for your input.
In fact, I did not know, how to build such a script. Fortunately, using Postman I was able to create something like that.
#!/bin/bash
auth=$(curl --location --request POST 'http://win-cv-new.listopad.local:81/SearchSvc/CVWebService.svc/Login' --header 'Accept: application/json' --header 'Content-Type: application/json' --data-raw '{
"password": "********",
"username": "admin"
}' | jq -r .token)
curl --location --request GET 'http://win-cv-new.listopad.local:81/SearchSvc/CVWebService.svc//Job?completedJobLookupTime=30000' --header 'Accept: application/json' --header 'Authtoken: '"$auth"''
*password is encoded with Base64 encoded password
I have just a question. Are there any parameters that can display only failed jobs? I did not see something similar here.
https://documentation.commvault.com/11.24/essential/47608_rest_api_get_job.html
So, the solution is only to parse json output using jq or with whatsoever tool?
And is it possible to somehow display only failed VMs, that are of course a part of a subclient. So, the subclients report, that backup was partially succesfull, but some of the VMs could failed. Can I using API find only these failed VMs?
Cheers!
Hi @drPhil
I have checked GET Job and GET JobDetails, but neither provide any parameters to filter on job status.
You would - as you suggest - need to collect and parse the json output to perform the filter on the response data.
I will check internally to see if there are any other ways to do this with REST API.
Thanks,
Stuart
Hi @drPhil
I’ve checked internally with Development and had a suggestion to use a slightly different approach, with POST Jobs API.
Please take a look at: https://api.commvault.com/#17736755-e86f-9a27-75c5-6c5e999bec80
You can specify different job statuses for a specific client, for example:
{
"pagingConfig": {
"sortDirection": 1,
"offset": 0,
"sortField": "jobStartTime",
"limit": 10
},
"jobFilter": {
"completedJobLookupTime": 1637370018,
"statusList": t
"Failed"
],
"jobTypeList": t
4
],
"entity": {
"clientId": 34
}
}
}
Where jobTypeList:4 is for Backup jobs.
For a full list of JobTypeList options:
https://documentation.commvault.com/11.24/essential/105923_jobfilter_parameter_values.html
Thanks,
Stuart
Hi @drPhil
Checking this a little further, Development have also confirmed as an alternative to clientId, you can also use subclientId within “entity:”
{
"pagingConfig": {
"sortDirection": 1,
"offset": 0,
"sortField": "jobStartTime",
"limit": 10
},
"jobFilter": {
"completedJobLookupTime": 1637370018,
"statusList": i
"Failed"
],
"jobTypeList": i
4
],
"entity": {
"subclientId": 202
}
}
}
Thanks,
Stuart
Hi @Stuart Painter! Thank you so much for your suggestion with putting focus on specific clients and then listing its jobs. It’s an creative option how to display only failed jobs using API calls. What made me troubles in my testing environment was that I was not able to list more clients associated in my commserver server, which could be caused by connectivity in my lab environment. Neverthless, even using API calls, it is possible to display failed backup jobs.