Authenticating to the IBM Cognos APIs

Authenticate so that you can access the IBM Cognos REST API services.

About this task

Before you begin, remove any cookies from previous work (rm cookie.text).

Procedure

  1. Obtain your Reporting domain name, tenant ID, and tenant instance ID from your Reporting application URL. You also require your CAMNamespace (<tenant ID>_<tenant instance ID>), your REST user ID, and your REST user password.
  2. Make a call to the Cognos APIs to initiate the session. Use the parameters that you obtained in Step 1 in the call.
    curl -v -b cookie.txt -c cookie.txt -X GET https://<Reporting domain name>/wcmreportingapi/<tenant id>/<tenant instance ID>/session

    The following snippet outlines an example:

    curl -v -b cookie.txt -c cookie.txt -X GET "https://care-manager01.us-south.wh-wcm.watson-health.ibm.com/wcmreportingapi/1234567/01/session"
  3. You must send an X-XREF-Token request header on all subsequent requests. The following outlines the call to make to obtain the cookie:
    xsrf=`grep XSRF cookie.txt | awk '{print $6}'`
    To check your output, use: echo $xsrf. Output should resemble the following: J-Av2dsLynUrMTnqfVU7nQbm5ZCufE7Q

  4. Make a call to the Cognos APIs to authenticate. Use the parameters that you obtained in Step 1 in the call.
    curl -v -b cookie.txt -c cookie.txt -X PUT "https://<Reporting domain name>/wcmreportingapi/<tenant id>/<tenant instance ID>/session" -H "X-XSRF-TOKEN: ${xsrf}" -H "Content-Type: application/json" -d '{"parameters":[{"name":"h_CAM_action","value":"logonAs"},{"name":"CAMNamespace","value":""<tenant ID>_<tenant instance ID>"/},{"name":"CAMUsername","value":""<REST UserID>"},{"name":"CAMPassword","value":""<REST USER password>"}]}'

    The following snippet outlines an example:

    curl -v -b cookie.txt -c cookie.txt -X PUT "https://care-manager01.us-south.wh-wcm.watson-health.ibm.com/wcmreportingapi/1234567/01/session" -H "X-XSRF-TOKEN: ${xsrf}" -H "Content-Type: application/json" -d '{"parameters":[{"name":"h_CAM_action","value":"logonAs"},{"name":"CAMNamespace","value":""1234567_01"/},{"name":"CAMUsername","value":""testuser@ibm.com"},{"name":"CAMPassword","value":""password1234"}]}'
    Output should resemble the following if you have authenticated successfully: {"generation":3,"shareable":false,"isAnonymous":false,"cafContextId":"CAFW000000dcQ0FGQThjMDAwMDAwMDlBaFFBQUFEQkRCcmVFMFNZVHM0c016aHhmLWZaaEpXbXBnY0FBQUJUU0VFdE5URXlRQUFBQUpmQVV2c3FXY1JHVFJtbnE0TXpCOXJQb1pObVUyRlhEajhTYVNRYld2dnpjOGVLWE4yQzEwTkVQMWR6QkU0My1mSWVyOHU0a0NTbEpkQWpvMWhwZ1ZZXzQ1MTcxOHxycw__","logEnabled":false,"canCallLogon":true,"url":"/bi/api"}* Closing connection 0