Question

Create Report in Command Center via RestAPI

  • 23 January 2024
  • 7 replies
  • 170 views

Badge +5
  • Commvault Certified Expert
  • 17 replies

 Does anyone have experience with creating Reports in Command Center using RestAPI?

When you schedule a Report in Command Center you have the possibility to have it give you the RestAPI equivalent.

By modifying that code to our needs (e.g. different Report name & recipients) we want to create Reports “automatically” with the API.

As we need to create many Reports quite often (as we run a Multitenant environment) a potential API usage would save us a lot of time.

When I try the POST command with the adjusted JSON payload to the URL mentioned (see screenshot below) it doesn’t work, no error, just nothing happens, so I’m wondering if there is something I’m missing.

 


7 replies

Userlevel 2
Badge +9

@ChrisK 

kindly refer below document


https://documentation.commvault.com/11.24/essential/rest_apis_for_reports.html#:~:text=You%20can%20use%20REST%20APIs,application%20on%20the%20Web%20Console.

Badge +5

@Pradeep  thank you for the link, but my challenge is not getting the data but to execute the RestAPI call using the payload generated from Command Center.

Userlevel 5
Badge +16

I think there may be some confusion on your part.

Are you saying you want to run a report after you have created it? For that you just need to get the dataset id for the report and execute this API:  REST API - GET Data Set (commvault.com)

 

The payload generated is for the exact report you are viewing the api definition for, to create that exact same report you would have to submit the json to the endpoint that you have redacted in the screenshot.

Badge +5

@christopherlecky Basically, I want to “clone” a Web Report in the Command Center but with different values.

  1. Create a Report in Command Center
  2. Export the API equivalent
  3. adjust the code accordingly in a python script (for example the E-Mail Recipient, Name of the Report etc.)
  4. Execute the python script to create the Report with the “new” values in Command Center

Steps 1-3 I have covered but my problem is Step 4. I haven’t found details on which API URL to run the POST command against. When I use the URL that is shown during step 2 (generating the API equivalent) and run the POST command against it nothing happens. So my guess is that there is a different URL to execute the POST command against or it needs something additionally. However, I haven’t found anything helpful in the documentation.

I’ve executed RestAPI commands in the past and it’s worked fine, but for the things I had to do then I could use the details provided in the documentation and the API Sandbox overview. But in regards to Web Reports in the Command Center there is nothing there.

Userlevel 5
Badge +16

Yeah that’s not cloning the report thats just running the report with custom values. 

The API you want is createtask, and the report would be run as a subtask with the equivalent api code in the subtask and the report intputs modified.

 

Typically if you look at the url of a report that you have run you will see something like this:

 

/reportdetails?reportId=85&input.clients=%58421%

 

That question mark denotes passing parameters to the server, so that is what you update to pass parameters to the server.

 

You can generate the code for createtask by clicking “more actions” → “email” then clicking equivalent api.

 

It will show you the createtask code including the report and its input parameters and the url for submitting the request.

 

Badge +5

@christopherlecky Thank you for the explanation, that makes more sense now.

Do you know if there’s a logfile where the API calls are logged?

I’m using Visual Studio and Postman to test the code but I’m getting errors that I need to investigate.

Userlevel 5
Badge +16

Workflowengine.log

 

also I suggest using visual studio code for powershell rather than visual studio.

Reply