Greetings from Malaysia! This week I’ve been doing some more exploring with ZENworks Reporting in my hotel time and I found that there’s a great solution available for those of you who want to get some data programmatically for integration with some other application in your environment. ZENworks Reporting provides a REST interface that makes it easy to execute domain queries against anything that has a Domain available and responds with the data. This cool solution will show you how to do this.
To get started you need the following things:
- A ZENworks Reporting Server appliance connected to your ZENworks server.
- JasperStudio needs to be installed and configured to connect to your ZENworks Reporting Server. You can see how to do this in this cool solution.
- A tool for generating REST requests and reviewing the responses. In this Cool Solution, I’ll be using the free version of Insmonia.
Let’s get started:
- Build a tabular Adhoc View that has the data you want to get via REST. This isn’t a hard requirement, but its the easiest way to get the name of the Domain fields that you want to return and use for a filter. There have been several cool solutions that include information on how to do this, or check out this video. For this solution I created a report from the ZENworks Bundle domain that looks like this:
- Create a Report based on the Adhoc View. To do this simply choose to do a Save as and Create Reporting for the Adhoc Editor. This creates a JRXML report in the repository that we’ll need for the next step.
- Now fire up JasperStudio so that you can find out what fields were used in your report. You’ll need the field names and filter string to build the XML document you need to submit with your query.
- Start JasperStudio.
- Under servers, expand your server and browse to where you saved your report. You can see mine below, be sure to expand your report as shown:
- Right-click mainReport.xml, then click the Source tab at the bottom of the middle pane in JasperStudio. Find the Field list similar to what you see below:
- Make a note of the fields in a text file somewhere that correspond to the values you included in the report.
- Right-click and open the state.jrxml in the report.
- Find the filter expression string that corresponds to the filter you added in the adhoc view. Make a note it in your text file.
- Close the report files, you don’t need to do anything else in JasperStudio.
- Now write your REST query using the data you found in the report. Here’s I’ll use Insomnia as the REST client.
- Open up Insomnia.
- Create a New Request.
- Name the Request ZENworks Bundle List and select the type as POST.
- In the Body Type, select XML.
- Click Create.
- Next, you need to know the path to the Domain that you want to query in the ZENworks repository. You can find this by opening the ZENworks Reporting console, finding the domain in the repository and then right-clicking and selecting Properties. It should show you something like the dialog below:
- In Insomnia enter the URL as shown below. Replace zenrpt.zendemo.com:8443 with your server and replace /Domains/ZENworks_Bundle_Domain with whatever domain you want to query.
- Next, you need to enter the query that you want to make. For this you need to use the fields and filter data that you identified from JasperStudio earlier. The format is shown below:
- Click the Auth tab and select Basic Authentication. Specify a credential set that has permissions to login to ZENworks reporting as shown below:
- You now have everything you need to run the query, so click the Send button next to the URL.
- Depending on the data you asked for and the amount of data in the database it may take some time to retrieve the data. Once its completed, review the response that came back. You can see a sample below. The response is an XML file that describes the table.
- You could then have application logic that would parse this output as you see fit.
Using this method you can get any information available to any of the available domains, including the ZENworks Domain, ZENworks Bundle Domain, ZENworks Audit Domain, ZENworks Service Desk Domain or the Micro Focus Desktop Containers Server Usage Domain and use that data in your consuming application.