If you are unable to create a new account, please email support@bspsoftware.com

Author Topic: How to get the XML output for Report outside of Cognos Viewer  (Read 6325 times)

Offline CognosPaul

  • Global Moderator
  • Statesman
  • *****
  • Join Date: Jan 2009
  • Posts: 1,912
  • Forum Citizenship: +269/-1
    • Paul's Cognos Blog
Re: How to get the XML output for Report outside of Cognos Viewer
« Reply #15 on: 15 Mar 2017 11:06:41 am »
I actually have no experience at all with PHP.

Can you post your code and whatever error's your getting? Are you using simplexml_load_file()? If so, try file_get_contents().

Can you try consuming a JSON output? Do you get the same or a different error?

mybrainhurts

  • Guest
Re: How to get the XML output for Report outside of Cognos Viewer
« Reply #16 on: 16 Mar 2017 06:29:45 am »
Good Morning Paul,

I am having troubles with JSON output as well. I am reading the documentation file you provided and it mentions there are  bunch of sample applications that perform the functions I am interested in. It would save me from having to keep bothering everyone if I could get my hands on these samples. I try the locations they indicate but nothing comes up (website declined to show this page). is there another way to get the sample files?

Thanks,
Mark

Offline CognosPaul

  • Global Moderator
  • Statesman
  • *****
  • Join Date: Jan 2009
  • Posts: 1,912
  • Forum Citizenship: +269/-1
    • Paul's Cognos Blog
Re: How to get the XML output for Report outside of Cognos Viewer
« Reply #17 on: 16 Mar 2017 09:03:22 am »
Start with reading this:

http://cognospaul.com/2013/02/18/cognos-mashup-services-a-brief-example/

It has an example of a method of running a report in JSON format and using the results in JS.

mybrainhurts

  • Guest
Re: How to get the XML output for Report outside of Cognos Viewer
« Reply #18 on: 16 Mar 2017 12:11:38 pm »
Hi Paul,

I've tried playing with your code but I feel I am experiencing the limitations of my skillset.

Here is where I am so far:

- I can get all the different types of output to load in an iFrame, but not outside of it. Trying to access the URL via an ajax or php call it brings back errors (essentially unable to fetch the xml, etc.)

This leads me to believe that when I load the output through the iframe my credentials must already be active in the browser, but when trying to get the output via ajax or php then those credentials are not passed to it. So, I have to figure out how I can do that and what the CMS needs from my end.

I will keep on trucking.

« Last Edit: 16 Mar 2017 12:36:34 pm by mybrainhurts »

Offline CognosPaul

  • Global Moderator
  • Statesman
  • *****
  • Join Date: Jan 2009
  • Posts: 1,912
  • Forum Citizenship: +269/-1
    • Paul's Cognos Blog
Re: How to get the XML output for Report outside of Cognos Viewer
« Reply #19 on: 16 Mar 2017 02:00:18 pm »
can you paste in the error? I'm really flying blind here. What is the iframe doing?

mybrainhurts

  • Guest
Re: How to get the XML output for Report outside of Cognos Viewer
« Reply #20 on: 21 Mar 2017 02:08:17 pm »
Hi Paul,

Well. I have finally been able to get the report output programmatically. =]

At the moment it is still a workaround as I am hardcoding the username and password until I can find another way to get it. I know that cognos uses my workstation login as my credentials but I just need to get that without having to ask a user to log in again to get the report.

The other road block now is getting the output sent to a php file so it can be written to a file on the server. I think I am just not getting the delivery right. I have faith I will get it all working. =]

Just wanted to update you. =]

Offline sdswaim71

  • Associate
  • **
  • Join Date: Sep 2023
  • Posts: 1
  • Forum Citizenship: +0/-0
Re: How to get the XML output for Report outside of Cognos Viewer
« Reply #21 on: 11 Sep 2023 10:04:53 am »
I am in a very similar situation.   I have Cognos 10.2.2.   I dont have any access to the actual database.   I need to pull the dataset from a report.   I used to be able to just run the report from php (with all of my parameters in the url including the USERNAME and PASSWORD) and parse the output. This has worked for years. But now, the output does not contain any data. I assume that the backend cognos was updated to a new version and that is my issue.  I have tried to modify the link with the information you have provided above but I get a problem loading page. 

Here is my goal
1.  using PHP, I would like to read the output data from the report.  Would love to automate this and not have to manually log in and run the report
2.  I cand use XML, CSV, even HTML
3.  I can then parse the data and place it in my local database for additional reporting.   
4.  I dont have any access to the original database.  (This is managed by another company).  The only access to the data is through Cognos.


Any help would be appreciated.

Thanks
Scott


Original Link
https://MYSERVER/p2pd/servlet/dispatch?b_action=cognosViewer&ui.action=run&ui.object=%2fcontent%2fpackage%5b%40name%3d%27eCWEBO%27%5d%2ffolder%5b%40name%3d%270%20-%20Custom%20Reports%27%5d%2ffolder%5b%40name%3d%27Admin%27%5d%2freport%5b%40name%3d%27VisitInfo%27%5d&ui.name=VisitInfo&run.outputFormat=XML&run.promptCSVlse&CAMUsername=<<username>>&CAMPassword=<<password>>

Modified using previous post
http://MYSERVER/p2pd/servlet/dispatch/rds/reportData/searchPath/content/folder[@name='Public%20Folders']/folder[@name='eCWEBO']/folder[@name='0%20-%20Custom%20Reports']/folder[@name='Admin']/report[@name='VisitInfo']?fmt=dataset&async=off