Thanks for your guidance. It means a lot.
Unfortunately i am not getting response on the swagger api tool.
After creating session on swagger, i am getting unauthorized message for next GET request.
I guess if swagger shows response then we can continue to postman and java etc.
Please correct me if i am wrong.
So i am little confuse, should i test it on java program or some another reason causing issue like we have custom authentication?
Please guide on this.
Original Message:
Sent: Fri May 28, 2021 02:38 AM
From: Jiri Smrz
Subject: REST API logon
Hi,
Andrew is right. You have to reuse all cookies. I am not aware of this implementation, but for instance in Java (with using apache.HttpClient), my process was following:
1. I send PUT request to create a session. I stored all cookies into a cookie store.
2. For other requests I manually adding X-XSRF-Token header with value from XSRF-Token cookie retrieved in step one, but I also reusing all cookies from step one because I initialized the cookie store in first step.
I also suppose that XSRF-Token cookie value has to match with X-XSRF-Token header.
------------------------------
Jiri Smrz
Original Message:
Sent: Mon May 24, 2021 04:57 AM
From: Amol Pukale
Subject: REST API logon
Hello @Jiri Smrz,
I am able to create session and getting response as following.
------------------------------
Amol Pukale
Original Message:
Sent: Thu May 20, 2021 04:59 AM
From: Jiri Smrz
Subject: REST API logon
Yes, you have to reuse all cookies from that session. And also you have to create new header X-XSRF-TOKEN with value you retrieved in XSRF-TOKEN cookie.
------------------------------
Jiri Smrz
Original Message:
Sent: Thu May 20, 2021 04:57 AM
From: Amol Pukale
Subject: REST API logon
Hi @Jiri Smrz,
I am getting following cookies and XSRF token. Do i need to pass all cookies in get request.
After passing all these, still i am getting{"message":"Authentication required."}

While creating session , iam getting canCallLogon": false,Is it ok or not?
------------------------------
Amol Pukale
Original Message:
Sent: Thu May 20, 2021 04:26 AM
From: Jiri Smrz
Subject: REST API logon
Sorry, that was my misunderstanding!! :-) I have the same JSON response.
XSRF-Token is part of cookies. You have to get this value from session headers. How to do that depends on your implementation. If you are using swagger from https://<cognos_analytics_server>:<port>/api/api-docs you can check it directly in your browser.
1.In Chrome/Edge (on Chromium) use shortcut CTRL + SHIFT + I. Developer console will open.
2. In developer Console, go to network tab
3. On Swagger, execute PUT request to create session
4. In Developer Console, on network tab new Cookies tab should be available. Here you can see your XSRF-Token cookie and its value.
------------------------------
Jiri Smrz
Original Message:
Sent: Thu May 20, 2021 04:02 AM
From: Amol Pukale
Subject: REST API logon
Hi @Jiri Smrz,
I am using cognos 11.1.7. And i am getting server response code 201(session created)
Response body{ "generation": 3, "shareable": false, "isAnonymous": false, "cafContextId": "CAFW000000a0Q0FGQTYwMDAwMDAwMDlBaFFBQUFDZUxHLWhHdEVBZTZFUW5neEw0Qi1TU2g1aGtRY0FBQUJUU0VFdE1qVTJJQUFBQUp6M2d6VXlUeWplNEdkVXk3cTBiUEo1S2IwOG1NR2xNS3dHQmNkamE4Kno0MTV8cnM_", "logEnabled": false, "canCallLogon": false, "url": "/api/v1"}
Response headers Thanks! --------- Amol --------- |
------------------------------
Amol Pukale
Original Message:
Sent: Thu May 20, 2021 02:55 AM
From: Jiri Smrz
Subject: REST API logon
Hello Amol,
I suppose ibmcognos/bi/v1/disp is legacy portal URL. You should be able to access to the REST API through this URL.
https://<cognos_analytics_server>:<port>/api/api-docs
See the REST API documentation .
So, for instance, to create session you have to run PUT request on https://<cognos_analytics_server>:<port>/api/v1/session
URL with following JSON body:
{ "parameters": [ { "name": "CAMNamespace", "value": "LDAP" }, { "name": "CAMUsername", "value": "johnsmith" }, { "name": "CAMPassword", "value": "mypassword" } ]}
As a response, you should get XSRF-Token key.
I also think that since CA 11.2.0 there is a change in logon action - you should be able to use cafContextId value in IBM-BA-Authorization header instead of reusing whole cookies. But unfortunately I have not had a time to test new Cognos version yet.
------------------------------
Jiri Smrz
Original Message:
Sent: Wed May 19, 2021 06:15 AM
From: Amol Pukale
Subject: REST API logon
Hi @Jiri Smrz,
I am not able to apply /session or /files or /extensions to url because my url is /ibmcognos/bi/v1/disp ,then how to use /session for getting XSRF-TOKEN?
And how to use /files and /extensions too?
----------------------
Amol
-------------------
------------------------------
Amol Pukale
Original Message:
Sent: Mon January 18, 2021 09:25 AM
From: Jiri Smrz
Subject: REST API logon
Hi Doug,
when I worked with REST API I found out, that I have to pass whole cookies set which I received from PUT /api/v1/session. You also have to add new header X-XSRF-TOKEN with value of XSRF-TOKEN which you received from PUT statement.
Then the other requests to the CA REST API are working fine. When I used only X-XSRF-TOKEN itself (without reusing cookies set from put statement), then I received "Authorization Required." error message.
------------------------------
Jiri Smrz
Original Message:
Sent: Fri January 15, 2021 09:57 AM
From: Doug Williams
Subject: REST API logon
Hi Adnan,
The Swagger API test page works fine. It's getting the requests to work using Postman or SoapUI where I'm having problems. I can create a Session using the PUT /api/v1/session request, but haven't been able to get any of the GET requests to work using the XSRF-TOKEN in the response. It seems that the other cookies in the response are used also, but I haven't verified that.
------------------------------
Doug Williams
Original Message:
Sent: Fri January 15, 2021 04:12 AM
From: Adnan Sheeraz
Subject: REST API logon
Dear Doug,
Have you tried this Swagger API Test Page after clearing the Cookies. Try it and then Restart the Cognos Server . hope it will work
------------------------------
Adnan Sheeraz
Original Message:
Sent: Thu January 14, 2021 10:23 AM
From: Doug Williams
Subject: REST API logon
Thanks, Reinier and Robert.
I was able to get the initial Session Put to work in SoapUI yesterday by adding the credential information as a JSON string instead of individual parameters.
------------------------------
Doug Williams
Original Message:
Sent: Thu January 14, 2021 09:40 AM
From: Robert Hofstetter
Subject: REST API logon
Martin,
I wrote an article on how to log in and utilize the new REST APIs using Python. The example might help since you will ultimately wish to move from Postman into an actual scripting language.
https://www.linkedin.com/pulse/scripting-new-rest-api-ibm-cognos-analytics-robert-hofstetter/
------------------------------
Robert Hofstetter
Original Message:
Sent: Sat August 15, 2020 12:47 PM
From: Martin Braun
Subject: REST API logon
Hello,
I want to use the new REST API controllers to upload Excel and CSV files from a 3rd party application.
However, any attempt to log in to the Cognos system using the REST controller /api/session fails.
(I use the REST tool POSTMAN)
URL:
http://<bi server hostname>:9300/bi/api/session
Method:
PUT
Header:
accept = application/json
content-type = application/json
Body:
{
"parameters": [
{
"name": "CAMNamespace"
"value": "<LDAP ID>"
},
{
"name": "CAMUsername"
"value": "<username>"
},
{
"name": "CAMPassword."
"value": "<password>"
}
]
}
I always get a "403 forbidden" error
If I test the same parameters in swagger, this works.
does anyone have an idea or experience with the REST controllers?
Best regards
Martin Braun
------------------------------
Martin Braun
------------------------------
#CognosAnalyticswithWatson