Skip to main content

I am starting to approach the use of APIs in the Commvault environment.

The goal is to extract a customized report created in the Command Center (Custom Report).

I have created a script that performs the login in the Command Center, and it works correctly (Script name: Login.py).

Next, I created a script that performs the login and then a GET request using the token received from the login (Script name: Get Report.py).

The URL for the GET request was taken from the Command Center by selecting REST API from the report.

I am attaching the listed scripts.

 

The error I receive is as follows:

 

/Get Report.py" Login successful! Authentication token: QSDK 393e4984a1a254f623019e8c20e221d0f3e04615ffde8c020f3aa3df4e67cf75efd3e01f34d86367be3e03948a9081e2177d34579743df1520bec81a0470b432be5345b3b75b548efbf61e02112b9026e4ee1db4b76c047e4844aca40ec0822e5d23124a0329d432af7ee137154079b4bf2b4815a1bc056fd73a9585a5dd2bd74f941c640faf0f99e38596fa6c25a4292bf03c2dedb6f135d56641413777c625c0682de01a558d7ce52886737e47cd2b60ee43c59f335491d9cc81897fb19d26f01b54beac8460095ec6143d47845fec72d8998af1cd87ab1 GET request headers: {'Accept': 'application/json', 'Authorization': 'Authtoken QSDK 393e4984a1a254f623019e8c20e221d0f3e04615ffde8c020f3aa3df4e67cf75efd3e01f34d86367be3e03948a9081e2177d34579743df1520bec81a0470b432be5345b3b75b548efbf61e02112b9026e4ee1db4b76c047e4844aca40ec0822e5d23124a0329d432af7ee137154079b4bf2b4815a1bc056fd73a9585a5dd2bd74f941c640faf0f99e38596fa6c25a4292bf03c2dedb6f135d56641413777c625c0682de01a558d7ce52886737e47cd2b60ee43c59f335491d9cc81897fb19d26f01b54beac8460095ec6143d47845fec72d8998af1cd87ab1'} GET URL: https://servername/webconsole/api/cr/reportsplusengine/datasets/02016422-320a-4854-9c6b-cc1b99d7d795:a30bd278-c7d9-470f-9ae9-8b4922743330/data/?offset=0&orderby=%5BJobId%5D%20Desc&parameter.timeframe=-PT24H%20P0D&parameter.useCSTimeZone=1&parameter.WindowStartTime=00%3A00%3A00&parameter.datasource%5B%5D=2&limit=20 Error during the GET. Status code: 401 Error message: {"errorCode":15000,"errorMessage":"Unauthenticated"}

 

Why is the token of type QSDK?

I can't understand where I'm going wrong; can someone help me fix the script?

Thank you.

Hi @luca matteazzi 

 

Have you tried like below and see if that works

 

            get_headers = {
                "Accept": "application/json",
                "Authtoken": f"{auth_token}"  # Dizionario chiuso correttamente
            }


Hi @Vignesh S ,

 

I tried it and it works. Thank you very much for your prompt response!

Now I need to process the JSON file to transform the output into a table. Thank you again!


I have used the json_normalize method of pandas to get a JSON string into a table. Is very easy.

Good luck !


Reply