Wanna read information from #ZENworks using REST?


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:

    1. A ZENworks Reporting Server appliance connected to your ZENworks server.


    1. 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.


    1. 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:

    1. 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:


    1. 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.


    1. 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.

        1. Start JasperStudio.

        1. 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:

        1. 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:

        1. Make a note of the fields in a text file somewhere that correspond to the values you included in the report.

        1. Right-click and open the state.jrxml in the report.

        1. Find the filter expression string that corresponds to the filter you added in the adhoc view. Make a note it in your text file.

        1. Close the report files, you don't need to do anything else in JasperStudio.


    1. Now write your REST query using the data you found in the report. Here's I'll use Insomnia as the REST client.

        1. Open up Insomnia.

        1. Create a New Request.

        1. Name the Request ZENworks Bundle List and select the type as POST.

        1. In the Body Type, select XML.

        1. Click Create.

        1. 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:

        1. 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. 

        1. 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:

        1. Click the Auth tab and select Basic Authentication. Specify a credential set that has permissions to login to ZENworks reporting as shown below:

        1. You now have everything you need to run the query, so click the Send button next to the URL.


    1. 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.


    1. 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.


New Release-Feature
How To-Best Practice
Comment List