Cognos Analytics

Cognos Analytics

Connect, learn, and share with thousands of IBM Cognos Analytics users! 

 View Only
  • 1.  Cognos Analytics API Authentication with API Key

    Posted 26 days ago

    I'm attempting to use the REST Api with Cognos Analytics 11.2.4, and am having trouble authenticating. I've used the reference here:

    https://www.ibm.com/docs/en/cognos-analytics/11.2.x?topic=api-rest-sample

    but so far no dice. I'm creating a body like this:

    {
      "credentials": {
        "parameters": [
          {
            "name": "CAMNamespace",
            "value": "<Namespace>"
          },
          {
            "name": "CAMAPILoginKey",
            "value": "<API Key>"
          }
        ]
      }
    }

    I continually get a 401 - Unauthorized error. Can anyone point me in the right direction for this?

    If it helps, my goal is to use the REST API to automatically update a data module from an Excel sheet.

    Thanks!



    ------------------------------
    Matt McNabb
    ------------------------------


  • 2.  RE: Cognos Analytics API Authentication with API Key

    Posted 25 days ago

    Matt,

    I thought this change was new to v12 but I recently noticed a similar issue in 12.0.4 so perhaps it was a change introduced with a recent fix pack in 11.2.4 even. Anyway, what I found out is you cannot initiate the authentication anymore without first having an XSRF token. The way to get that is to first send a GET request to /api/v1/session without a payload and capture the cookie. Include that then on your PUT request to actually authenticate (and of course all subsequent requests). Try that and see if it works.



    ------------------------------
    Robert Hofstetter
    ------------------------------



  • 3.  RE: Cognos Analytics API Authentication with API Key

    Posted 23 days ago

    Robert,

    Thanks for the response! I just tried that and unfortunately it didn't work - I get a 404 on a GET request to the session endpoint. At this point I'm not sure the Cognos server is set up properly for the API.

    I did find some other information on API authentication in v11 in the meantime. I found this documentation and it doesn't mention authenticating via an API Key

    https://www.ibm.com/docs/en/cognos-analytics/11.2.x?topic=api-rest-sample

    I am able to generate a key though, so I'm a little confused. I'll keep digging in case I can find something.



    ------------------------------
    Matt McNabb
    ------------------------------



  • 4.  RE: Cognos Analytics API Authentication with API Key

    Posted 23 days ago

    HI Matt,

    I think this is what you are looking for:

    {
      "parameters": [
        {
          "name": "CAMAPILoginKey",
          "value": "yourapikey"
        }
      ]
    }



    ------------------------------
    Greg McDonald
    Product Manager - Cognos Analytics
    IBM
    greg.mcdonald@ca.ibm.com
    https://www.linkedin.com/in/greg-mcdonald-6743961/
    ------------------------------



  • 5.  RE: Cognos Analytics API Authentication with API Key

    Posted 23 days ago

    Hi Matt,

    I searched our 11.2.4 documentation and cannot find it but this is the Doc link.  this should apply to 11.2.4.   This was the first release that we exposed this feature so I feel that this is just a documentation issue.

    https://www.ibm.com/docs/en/cognos-analytics/12.0.x?topic=api-getting-started-rest#c_ca_api_rest_getstarted__title__2

    Greg



    ------------------------------
    Greg McDonald
    Product Manager - Cognos Analytics
    IBM
    greg.mcdonald@ca.ibm.com
    https://www.linkedin.com/in/greg-mcdonald-6743961/
    ------------------------------



  • 6.  RE: Cognos Analytics API Authentication with API Key

    Posted 23 days ago

    Greg,

    I had read through the v12 documentation and started there, but to no avail. Any PUT requests to the /api/v1/sessions endpoint returns a 401 unauthorized error from the server. I tried both with password auth and with API key auth as shown in that document. I should note that we have SSO set up with Cognos, and there are no native Cognos accounts on the system. Based on the docs I believe API key auth is the correct path for our scenario.

    It's also worth mentioning that our Cognos software is provided as part of another software package through a software vendor. In other words, I didn't perform the installation and don't have a ton of insight into how it was configured. Is it possible that further configuration is required to make our API functional? If so, is there guidance on that? I am able to investigate our configuration, so at the least with that knowledge in hand I could work with our vendor to get the API set up.

    The good news is that with a bit of study we were able to address our immediate needs without the use of the API, and further investigation into the API is now just for my own curiosity. I'd like to see what additional capabilities it will provide us in the future.

    Thanks all!



    ------------------------------
    Matt McNabb
    ------------------------------



  • 7.  RE: Cognos Analytics API Authentication with API Key

    Posted 20 days ago
      |   view attached

    Hi Matt,

    Does this help? It's not an official document but may help explain some steps.



    ------------------------------
    TREVOR COMEAU
    ------------------------------



  • 8.  RE: Cognos Analytics API Authentication with API Key

    Posted 19 days ago

    SSO is definitely the problem here. Basically the webserver is trying to authenticate the user before the authentication request has been submitted. The solution I've found for SSO implementations is to make a URL rewrite rule in a location that is not covered by SSO. 



    ------------------------------
    Paul Mendelson Product Manager
    Product Manager
    PMsquare
    ------------------------------