Is it possible to disable/enable the schedule of report via API endpoint. I was able to connect to Cognos server and get items of report using Gateway/v1/content/<OBJECT ID>/items. From there I took scheduleID value and used here Gateway/v1/content/<SCHEDULE ID>/items, but this didn't give any result. If you can give any suggestions about this, that would be great.
Original Message:
Sent: Tue February 07, 2023 05:31 AM
From: Paul Mendelson
Subject: Can I set up a schedule using the Cognos REST API?
I do want to assure you that everything you're asking for is possible. I recommend using the developer toolbar and monitoring the network tab to see exactly how Cognos does it. Just write your application around what you see.
Creating a report:
Post request: GATEWAY/bi/v1/reports
http://localhost/ibmcognos/bi/v1/reports
Creating a schedule:
Post request: GATEWAY/bi/v1/admin/objects/<OBJECT STORE ID>/items
http://localhost/ibmcognos/bi/v1/admin/objects/i7B660E4D1C664504A9C951DDBB978DCE/items
applying parameters:
PUT request: GATEWAY/bi/v1/objects/<OBJECT STORE ID>
http://localhost/ibmcognos/bi/v1/objects/i7B660E4D1C664504A9C951DDBB978DCE
Feel free to contact me directly and I'll be able to help you more.
------------------------------
Paul Mendelson
Original Message:
Sent: Mon February 06, 2023 06:31 AM
From: TOSHIYA HAYASHI
Subject: Can I set up a schedule using the Cognos REST API?
Hi Andrew,
I just want to confirm one thing since a team member is concerned about it.
Regarding the three processes you described, if it can be done with SOAP, wouldn't it be possible to achieve it with a REST API?
Is it not possible to achieve this with the REST API?
・creating reports (ReportAdd)
・applying parameters (ReportParams)
・scheduling (Scheduler)
------------------------------
TOSHIYA HAYASHI
Original Message:
Sent: Tue January 31, 2023 08:59 AM
From: Andrew Stalker
Subject: Can I set up a schedule using the Cognos REST API?
Hayashi-San,
There are certainly advantages to both Report Views and REST API but some thoughts on possible alternatives in case helpful:
#1 Cognos Bursting
In case you're not aware of it and have not ruled it out, the Cognos Bursting feature (link below) allows a report author to achieve a result similar to what you're describing and may prove helpful. For one report that has bursting enabled, that report can be scheduled to run and create multiple report outputs - a separate report output (with or without security applied so that only certain users see certain data) for each of a range in parameter/filter values (for example a region report might be burst to create a saved output for each region such that regional staff can access reports with their data.
These burst saved outputs can be emailed to users and/or users can access the output in the portal underneath the report - as mentioned either with or without security applied so that users only see the saved outputs relevant to them.
Bursting works well when:
- The requirement is only to burst on one or at most a few parameters but it not practical when the requirement involves a large number of parameters.
- The scheduling requirement can be satisfied by regular large bursts (eg daily, weekly, monthly-type regularity) as opposed to fine grain ad hoc frequency.
- It's beneficial to burst to the full range of parameter values.
- For scalability, break large parameter ranges into smaller chunks (eg rather than burst an employee report in one go to 30,000 saved outputs, instead do scheduled burst runs in smaller batches eg 50 at a time).
Enabling Bursting in a report requires some changes by a report author but is a very powerful Cognos feature.
DOC: Set Burst Options
https://www.ibm.com/docs/en/cognos-analytics/11.2.0?topic=reports-set-burst-options
#2 Cognos SDK Java SOAP Samples
Otherwise, I wanted to also highlight that if your goal is to use Java rather than JavaScript and you don't mind using SOAP rather than REST API then you'll likely want to have a look at the Cognos JAVA SDK examples that come bundled with Cognos (location below). There's not one single code sample (that I'm aware of) that does all of what you've described but there are samples on creating reports (ReportAdd), applying parameters (ReportParams) and scheduling (Scheduler).
NOTE: These are SOAP not REST API but is a supported way that can be used to achieve your described requirements.
You'll find the SDK samples <cognos_install>/sdk/java/*
See also the SDK Developer Guide documentation - for example - here's the documentation on creating a schedule in Java:
https://www.ibm.com/docs/en/cognos-analytics/11.2.0?topic=examples-example-schedule-report
Cheers,
Andrew
------------------------------
Andrew Stalker
Original Message:
Sent: Mon January 30, 2023 12:30 AM
From: TOSHIYA HAYASHI
Subject: Can I set up a schedule using the Cognos REST API?
Thank you for your answer.
But I am really sorry. My question was not a good one.
My question was not how to set parameters at report view runtime.
It is the way to store the parameter values in "Current values" in the Report TAB of the properties of the reportview.
We can save the executed report in the Content Store by doing a scheduled run. (*We are aware that HTTP access from JAVA to run a report does not allow us to save an executed report in the Cotent Store).
Having a report view for each parameter value in the same report definition would make it easier for end users to retrieve the executed reports they need.
Therefore, I need to create a report view, save the parameter values, and then run it on a schedule. I would like to achieve this task with a JAVA program.
------------------------------
TOSHIYA HAYASHI
Original Message:
Sent: Fri January 27, 2023 07:27 AM
From: Paul Mendelson
Subject: Can I set up a schedule using the Cognos REST API?
When connecting through Java you'll need to create a new session with at least read and execute permissions to whatever resources you want to make the report view of, and write permissions to wherever you want to save. https://www.ibm.com/docs/en/cognos-analytics/11.2.0?topic=api-rest-sample
When making the request you can set the parameters with the following JSON as part of the XMLHttpRequest:
[{"name": "Country",
"value": [
{"use": "1",
"type": "simpleParmValueItem",
"inclusive": true,
"display": "USA"},
{"use": "2",
"type": "simpleParmValueItem",
"inclusive": true,
"display": "Canada"}
]}]
------------------------------
Paul Mendelson
Original Message:
Sent: Thu January 26, 2023 08:50 PM
From: TOSHIYA HAYASHI
Subject: Can I set up a schedule using the Cognos REST API?
Thank you for your comment.
I want to do these things from a Java batch program placed outside of Cognos.
Can I set parameter values and schedule when I run the REST API from a Java batch?
------------------------------
TOSHIYA HAYASHI
Original Message:
Sent: Wed January 25, 2023 05:57 AM
From: Paul Mendelson
Subject: Can I set up a schedule using the Cognos REST API?
I would say that you don't need CogBox, it just has a lot of the work you're asking for.
It also depends greatly on where you're looking to trigger this. One of the controls I've made is a button that will take the report the user has run and save that as a report view with the selected parameters to the user's My Folder. But if you're looking to automate this from outside of Cognos, this absolutely won't help.
Regarding your list:
- Check to see if the report view to be executed already exists
As long as you have a consistent naming convention, you can do a searchpath query to check if it exists
- If not, copy the report view
- Rename the copied report view
- Change the value of a parameter of the copied report view
When you're saving the report view, a few things happen.
- The logged in user needs to have permissions to save to the specified folder
- When you create the object you'll specify the name and parameter values.
- Set a trigger type schedule for the copied report view
Not a problem, just sniff what happens when you create a schedule for another object and use that as a template
- Fire the trigger and execute the report view
A bit more tricky, do you want to run the triggername, which might trigger other schedules as well, or just the schedule of the new object?
- Verify that the scheduled report has been successfully saved to the Content Store
Also tricky - you can run the schedule but I haven't found a way to get a notification on success or failure. You'll just have to check the execution history of the object periodically.
If you want to make this a button that exists in the report, I've done similar things often enough that this should only take a couple days of development. Outside of Cognos, like part of a third party ERP, you'll need to handle authentication and a few other issues.
------------------------------
Paul Mendelson
Original Message:
Sent: Wed January 25, 2023 12:06 AM
From: TOSHIYA HAYASHI
Subject: Can I set up a schedule using the Cognos REST API?
One more additional question.
Do I need to add "CogBox" as an extension to Cognos to set parameters and schedule report views as I asked above?
Thank you in advance.
------------------------------
TOSHIYA HAYASHI
Original Message:
Sent: Tue January 24, 2023 03:35 AM
From: Paul Mendelson
Subject: Can I set up a schedule using the Cognos REST API?
You can do both, but they're not officially supported or even listed in the documentation. I have a method for updating parameters in reports and reportviews already in CogBox, and I just added a copy/paste schedule to it as well.
In both cases you need to first get the storeID of the object, the properties of the report will give it to you. It will be a 33 character string beginning in "i"
iED5A1D764CCB44818AB495DEB659F55C
With that you can construct the URL you need.
var url = gateway + '/v1/objects/'+id
http://server/ibmcognos/bi/v1/objects/iED5A1D764CCB44818AB495DEB659F55C
For the parameters you're running a PUT and the schedule it's a POST (unless the schedule already exists).
The request will look like this:
fetch("https://SERVER/ibmcognos/bi/v1/objects/iED5A1D764CCB44818AB495DEB659F55C", {
"headers": {
"cafcontextid": cafcontext,
"x-xsrf-token": tokenid
},
"body": "{\"parameters\":[{\"name\":\"param1\",\"value\":[{\"type\":\"simpleParmValueItem\",\"display\":\"a\",\"use\":\"a\"}]},{\"name\":\"param2\",\"value\":[{\"type\":\"simpleParmValueItem\",\"display\":\"b\",\"use\":\"b\"},{\"type\":\"simpleParmValueItem\",\"display\":\"c\",\"use\":\"c\"}]}],\"type\":\"report\"}",
"method": "PUT",
"mode": "cors",
"credentials": "include"
});
The schedule is similar but a little more complicated. It's a post request. The body object looks like this:
Object.keys(a)
(55) ['id', 'type', 'defaultDescription', 'state', 'notification', 'permissions', 'hasChildren', 'hidden', 'selected', 'position', 'searchPath', 'ancestors', 'modificationTime', 'disabled', 'capabilities', 'isDirty', 'options', 'printerSelection', 'optionsKey', 'parameterKey', 'parameters', 'executionPrompt', 'parentRunnable', 'triggerName', 'priority', 'endDate', 'everyNPeriods', 'endType', 'usage', 'scheduleRecurrence', 'periodicalProducer', 'credential', 'currentUserCredential', 'isMyCredentials', 'active', 'monthlyRelativeWeek', 'monthlyRelativeDay', 'monthlyAbsoluteDay', 'scheduleType', 'startDate', 'yearlyRelativeDay', 'yearlyAbsoluteDay', 'yearlyRelativeWeek', 'yearlyAbsoluteMonth', 'yearlyRelativeMonth', 'dailyPeriod', 'scheduleBy', 'weeklySunday', 'weeklyMonday', 'weeklyTuesday', 'weeklyWednesday', 'weeklyThursday', 'weeklyFriday', 'weeklySaturday', 'timeZoneID']
The easiest way is to create a schedule and use the browser toolbar to see exactly what it's doing:
Now obviously this is not supported. The official API and documentation can be found here: https://www.ibm.com/docs/en/cognos-analytics/11.2.0?topic=SSEP7J_11.2.0/com.ibm.swg.ba.cognos.ca_api.doc/swagger_ca.json
Feel free to reach out to me. I specialize in this kind of thing, and depending on what you're looking to do I can add this to cogbox.
------------------------------
Paul Mendelson
Original Message:
Sent: Mon January 23, 2023 01:15 PM
From: TOSHIYA HAYASHI
Subject: Can I set up a schedule using the Cognos REST API?
Hi Team,
I have quesions about Cognos REST API.
Can I use the Cognos REST API to do the following operations?
- Set parameter values in a reportview.
- Set up a schedule (trigger type schedule)
Thanks!
------------------------------
TOSHIYA HAYASHI
------------------------------