Thanks a lot Jim. The outputFormat resource worked out well. I am able to get the report in a PDF version. However there seems to be some error regarding the passing of my parameters. The returned PDF Report did not have any values.
Original Message:
Sent: Thu September 28, 2023 09:04 AM
From: Jim Boland
Subject: Python Cognos Analytics with REST API
Hi Srihari,
Yes, CMS has two different - somewhat overlapping - RDS resources:
- the reportData resource that you tried has the following formats (i.e. "fmt=") supported :LDX (XML), Simple (XML), HTML, HTML fragment, JSON, DataSet XML/ATOM/JSON, and Image. These formats are NOT the report server formats you can choose in the CA portal. (Instead, they are formats built to facilitate embedding/"mashing-up" report content into another application/environment. (e.g. PDF is NOT one of the fmt supported for this call.)
- the outputFormat resource, on the other hand, runs/returns the report output in one of the formats you can generate in the CA portal (e.g. CSV, MHT, PDF, spreadsheetML, XLWA, XML, xlsxData). This is the REST call, I believe you want to use, for the scenario you described (more details here).
You can specify the specific report, and the prompt parameters in the same way for either of these call (outputFormat or reportData).
E.g. your call probably looks something like:
https://<my-server>/ibmcognos/bi/v1/disp/rds/outputFormat/report/iD9493B2B788C40B7BFD20C92888EE745/PDF&p_client_id=<selectChoices><selectOption useValue="client_id" displayValue="client_name"/></selectChoices>
------------------------------
Jim Boland
LinkedIn: https://www.linkedin.com/in/jimboland
Website: https://coreinsightz.com
Email: jimboland@coreinsightz.com
Original Message:
Sent: Wed September 27, 2023 03:47 PM
From: SRIHARI CHANDRAMOULI
Subject: Python Cognos Analytics with REST API
Thanks a lot Jim. I was able use the REST API option within CMS. However, I want PDF as the format of the returned output. And it looks like "fmt" does not give me an option to export it as PDF
https://www.ibm.com/docs/en/cognos-analytics/11.2.0?topic=options-fmt
So far,
- I was able to use the mashup API to authenticate using auth/logon
- I was able to construct the URL as follows which returned an XML structure when I pasted it in my browser window. Here is the URL:
https://<my-server>/ibmcognos/bi/v1/disp/rds/reportData/report/iD9493B2B788C40B7BFD20C92888EE745?fmt=PDF&p_client_id=<selectChoices><selectOption useValue="client_id" displayValue="client_name"/></selectChoices>
- fmt=HTML works but things look out of place
- I guess I will find out a way to export PDF via REST API?
Any help appreciated
------------------------------
SRIHARI CHANDRAMOULI
Original Message:
Sent: Wed September 27, 2023 04:42 AM
From: Jim Boland
Subject: Python Cognos Analytics with REST API
Hi Srihari,
Yes the "new Cognos REST API" (i.e. https://www.ibm.com/docs/en/cognos-analytics/11.1.0?topic=apis-rest-api ) is mostly focused on automating the administrative operations of CA (e.g. managing users/groups/roles, UI customization like extensions and themes, Content Manager content, datasources/modules, etc.)
Probably more suited to what you are trying to accomplish is the Cognos Mashup Service ( https://www.ibm.com/docs/en/cognos-analytics/11.0.0?topic=guide-developing-mashup-service-applications-using-rest-interface ) - and specifically the REST API option within CMS. With it, you can login into Cognos, run reports (including specifying the parameters for prompted reports). As well if you want the resulting report output returned (as opposed to just run and saved in the CA portal) you can specify the format you want the report results returned in (e.g. image, HTML, HTML fragment, XML, JSON. Or you can ask for the report in one of the report viewer formats (e.g. PDF, Excel, etc.). Unlike the automation of administrative tasks role of the "new REST API", Cognos Mashup service is more a web service to your reports themselves.
Note: if you are looking to actually programmatically consume the results of the report in Python (e.g. pandas), Cognos has created a python module, CADataConnector, to allow you to work with (create and read) CA data resources directly in python, without using reports. CADataConnector is not published by itself, but is included in the IBM Cognos Analytics for Jupyter Notebook Server and in Watson Studio Notebook environment .
------------------------------
Jim Boland
LinkedIn: https://www.linkedin.com/in/jimboland
Website: https://coreinsightz.com
Email: jimboland@coreinsightz.com
Original Message:
Sent: Mon September 25, 2023 11:25 AM
From: SRIHARI CHANDRAMOULI
Subject: Python Cognos Analytics with REST API
Hey Community and Experts,
I would like to generate Cognos reports using Python. Is this possible at all? I could not find any documentation regd. running of reports programatically. There is Cognos Documentation regarding REST APIs but I could not find anything related to running of Reports.
Here is what my request is:
Does the Cognos API allow us to specify the following:
- which report to run
- with the appropriate parameters for example - customer, time range, etc...
I want to use Python to achieve this.
NOTE: I have used parameterized URLs that will return customized urls. But I want to achieve this via REST APIs and python. Any help appreciated.
#Cognos Analytics with Watson
------------------------------
SRIHARI CHANDRAMOULI
------------------------------