Cognos Analytics

 View Only
Expand all | Collapse all

Can I disable/enable a schedule using the Cognos REST API?

  • 1.  Can I disable/enable a schedule using the Cognos REST API?

    Posted Fri February 24, 2023 05:47 AM
    Edited by Bek Ibragimov Fri February 24, 2023 06:19 AM

    Hello Everyone,

    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.

    Here is t he code I'm using:

    $headers = @{
        "IBM-BA-Authorization" = "Generated_API_KEY"
        "Content-Type" = "application/json"
    }
     
    $body = "{
    `n    `"parameters`": [
    `n        {
    `n            `"name`": `"CAMNamespace`",
    `n            `"value`": `"<Our_Namespace>`"
    `n        },
    `n        {
    `n            `"name`": `"CAMUsername`",
    `n            `"value`": `"<UserName>`"
    `n        },
    `n        {
    `n            `"name`": `"CAMPassword`",
    `n            `"value`": `"<Password>`"
    `n        }
    `n    ]
    `n}'"
    [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
    $response = Invoke-RestMethod 'https://<cognos_server_url>/api/v1/session' -Method 'PUT' -Headers $headers -Body $body
    $response | ConvertTo-Json
     
    $NewAuthorization=$response.session_key
     
     
    $newheaders = @{
        "IBM-BA-Authorization" = "$NewAuthorization"
        "Content-Type" = "application/json"
    }
     
    $response1 = Invoke-RestMethod 'https://<cognos_server_url>/api/v1/content/<ScheduleID>/items' -Method 'GET' -Headers $newheaders
    $response1 | ConvertTo-Json
     
    Write-Host $response1

    Thank you


    ------------------------------
    Bek Ibragimov
    ------------------------------



  • 2.  RE: Can I disable/enable a schedule using the Cognos REST API?

    IBM Champion
    Posted Fri February 24, 2023 09:24 AM

    Hi Bek,

    Since you already have the objectID for the schedule this is very easy.

    Try this:

    url: `${gateway}/v1/admin/objects/${scheduleId}`

    method:`PUT`

    body: `{"id":"${scheduleId}","type":"schedule","active"}`



    ------------------------------
    Paul Mendelson
    ------------------------------



  • 3.  RE: Can I disable/enable a schedule using the Cognos REST API?

    Posted Fri February 24, 2023 10:22 AM
    Edited by Bek Ibragimov Fri February 24, 2023 12:58 PM

    Hi Paul,

    Thank you for the answer. I was able to change schedule with this:

    Methed : PUT

    URL: https://company_url/api/v1/content/scheduleID

    body = "{
    `n    `"type`": `"schedule`",
    `n    `"active`": false
    `n}"