Question

API call to show failed backup jobs

  • 25 November 2021
  • 2 replies
  • 19 views

Userlevel 3
Badge +10

Hi all,

 

I need to display failed backup jobs from yesterday using a script. In REST Webservice API Sandbox I am able to create API call - see below.

Is it possible to run this API call as part of the script from Linux shell (as a curl command) or from Powershell? Or are API calls executable only as part of /from C#, Python, Ruby or Postman?

 

Your help will be much appreciated!

 

GET SearchSvc/CVWebService.svc/Job HTTP/1.1
Host: win-cv-new.listopad.local:81
Accept: application/xml
Cookie2: QSDK 3c6ff3754c98e6b114bac8d6f751e1338d6ed01fb5a0dcf1abae25a51ddbf94bc8663b0b17632c829925b4447467b33075c9b41b52f765a7a1361f1ecffbd228e55980d2dcb805798d652cd364c0e64cc9ed6c0ce6af6e6c8b43c63b1a5791f04cdcde6a7f61db3827e9ae400eea2d6d971493994686d96c2f17b8bd959b8fe864f330e2a2503ee3e96b67b8f568462ac4ca2f9d20112401c80fe055bcee5c35b06f2744a83f76443fa25aa7f9c965625a33ab72a7f4ab3fdcfbf85df3d292ce67f3f7843e5f817a04163838fb982db422306577c98ffae3c254db77b7f8d28a083f3bcab1af341a55c1e67e3eb952dfbe89c52663d922f1a79a14db15132fb3fb4d41804257e544346f6e92c9a45a624


2 replies

Userlevel 7
Badge +14

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

 

 

Userlevel 3
Badge +10

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": "U3R1ZGVudDEyMzQu",
  "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!

 

 

 

Reply