Cognos Analytics with Watson

 View Only
Expand all | Collapse all

Can I set up a schedule using the Cognos REST API?

  • 1.  Can I set up a schedule using the Cognos REST API?

    Posted 13 days ago
    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
    ------------------------------


  • 2.  RE: Can I set up a schedule using the Cognos REST API?

    IBM Champion
    Posted 12 days ago
    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
    ------------------------------



  • 3.  RE: Can I set up a schedule using the Cognos REST API?

    Posted 11 days ago
    Edited by TOSHIYA HAYASHI 11 days ago
    Hi Paul,
    Thank you for reply.

    Actually, I'm currently looking into the possibility of using the REST API to perform the following operations in a batch process.

    - Check to see if the report view to be executed already exists
     - If not, copy the report view
     - Rename the copied report view
     - Change the value of a parameter of the copied report view
     - Set a trigger type schedule for the copied report view
    - Fire the trigger and execute the report view
    - Verify that the scheduled report has been successfully saved to the Content Store

    *The report view copies the values specified in the prompt to the key. This makes it easier to find saved reports.

    It seems that this can be done from the information you have already linked to me, but we would like to know how these operations can be accomplished with the REST API.


    ------------------------------
    TOSHIYA HAYASHI
    ------------------------------



  • 4.  RE: Can I set up a schedule using the Cognos REST API?

    Posted 11 days ago
    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
    ------------------------------



  • 5.  RE: Can I set up a schedule using the Cognos REST API?

    IBM Champion
    Posted 11 days ago
    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. 
    1. The logged in user needs to have permissions to save to the specified folder
    2. 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
    ------------------------------



  • 6.  RE: Can I set up a schedule using the Cognos REST API?

    Posted 10 days ago
    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
    ------------------------------



  • 7.  RE: Can I set up a schedule using the Cognos REST API?

    IBM Champion
    Posted 9 days ago
    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
    ------------------------------



  • 8.  RE: Can I set up a schedule using the Cognos REST API?

    Posted 6 days ago
    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
    ------------------------------



  • 9.  RE: Can I set up a schedule using the Cognos REST API?

    Posted 5 days ago
    Edited by Andrew Stalker 5 days ago
    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
    ------------------------------



  • 10.  RE: Can I set up a schedule using the Cognos REST API?

    Posted 4 days ago
    Thank you for your comment.

    Exactly!
    I believe that if I can't do it with the Java REST API then I have to use the Cognos Java SDK.
    And, as you advised, I assume that the Cognos Java SDK can probably make it happen.
    One of my concerns is that the Java 8 support used by the Cognos Java SDK will end in a few years, so if you have disclosed a roadmap for the Cognos SDK after Java 8 support expires, could you please let me know?


    I understand that burst reporting is one effective way to do this.
    However, I recognize that with burst reports, a report is always created for the value of the item set as the burst key.
    Even if only one report is really needed, if there are 10 values, 10 reports will be created.
    In the case of burst reports that are run daily, the number of unnecessary reports would be too large.

    Thank you.

    ------------------------------
    TOSHIYA HAYASHI
    ------------------------------



  • 11.  RE: Can I set up a schedule using the Cognos REST API?

    Posted 5 days ago
    Dear all

    While executing the report view, is there a paging option in the json file which we define the parameters through the rest api as mentioned below? (E.g. 20 rows in each consequtive requests)

    Regards
    Sukru