I was close 😎.
Original Message:
Sent: Thu January 04, 2024 09:38 PM
From: Jim Boland
Subject: API Authentication - Forbidden
Hi Thomas,
Yes - the ca_data_connector package you found in the CA notebook container is exactly what I'm talking about. ;-)
Almost - you want to use the CADataConnector.connect( ) method. It is overloaded to handle the various environments (e.g. special cases for CP4D, Watson Studio, IBM IBM Cognos Analytics for Jupyter Notebook Server, and the more general case you want to use.) I don't have access to an environment at the moment to look at it, but from memory I think it was something like this:
CADataConnector.connect(
{'url':'…' ,
'namespace': '…',
'user': '…' ,
'password':'…'
});
where url is the URL for the CA gateway, namespace/username/password are the CA authentication credentials. ("user" may be "username" ... can't remember ;-) )
------------------------------
Jim Boland
LinkedIn: https://www.linkedin.com/in/jimboland
Website: https://coreinsightz.com
Email: jimboland@coreinsightz.com
Original Message:
Sent: Thu January 04, 2024 05:43 AM
From: Thomas Strehl
Subject: API Authentication - Forbidden
Hi Jim !
You are talking about /usr/local/lib/python3.11/site-packages/ca_data_connector in the notebook container ?
With authentication along https://developer.ibm.com/apis/catalog/cognosanalytics--cognos-analytics-rest-api/Getting%20Started and Ash's approach ?
Or use CADataConnector.login(host, username=None, password=None, login_body=None) ?
------------------------------
Thomas Strehl
Original Message:
Sent: Wed January 03, 2024 07:20 AM
From: Jim Boland
Subject: API Authentication - Forbidden
Hi Thomas,
While the CADataConnector package works just fine in a stand-alone Jupyter environment, IBM has not publically released it as its own package. (It is only bundled, under the covers, in "IBM Cognos Analytics for Jupyter Notebook Server" and in "IBM Watson Studio". )
------------------------------
Jim Boland
LinkedIn: https://www.linkedin.com/in/jimboland
Website: https://coreinsightz.com
Email: jimboland@coreinsightz.com
Original Message:
Sent: Wed January 03, 2024 05:15 AM
From: Thomas Strehl
Subject: API Authentication - Forbidden
Hi Jim !
Any chance to use CADataConnector python/R packages in standalone Jupyter environments (other than CP4D or CA NB server) to access data assets in CA ?
------------------------------
Thomas Strehl
Original Message:
Sent: Thu January 26, 2023 02:56 PM
From: Jim Boland
Subject: API Authentication - Forbidden
Hi Andrea,
I assume you are using a standalone Jupyter environment, and Ash's response is a great answer (copying the XSRF token to the header as he described is key). However, for completeness I wanted to mention that if you use the integrated IBM Cognos Analytics for Jupyter Notebook Server Or IBM Watson Studio as your Jupyter environment, you can connect/login to CA much easier (through the built in CADataConnector python/R class. Even better, the CADataConnector will allow you to work easily with data assets in CA.
------------------------------
Jim Boland
LinkedIn: https://www.linkedin.com/in/jimboland
Original Message:
Sent: Thu January 19, 2023 07:55 AM
From: Andrea Paviglianiti
Subject: API Authentication - Forbidden
I need to demonstrate Cognos Analytics API on a Jupyter Notebook.
The documentation is very vague about the authentication method, it does not specify directly how to connect.
In the following code snippet there are a few parameters I could not figure out
- CAMUsername: is this my subscription ID, my registration email or else?
- CAMPassword: is it a Cognos API key, or my password, or else?
- With email and password the request feedback "forbidden"
{ "parameters": [ { "name": "CAMNamespace", "value": "LDAP" }, { "name": "CAMUsername", "value": "johnsmith" }, { "name": "CAMPassword", "value": "mypassword" } ]}
Using a different system (see code below):
- header may be wrong, I did not find alternatives other than "X-IBM-Client-ID"
- instance_id is another vague term so I am using the basic link you see in the snippet
- this operation returns status code: 200 but not a JSON.
# Set the headers for the requestheaders = { "X-IBM-Client-Id": api_key, "Content-Type": "application/json"}# Send a request to the root endpointresponse = requests.get("https://eu.ca.analytics.ibm.com/api/v1", headers=headers)# Check the status code of the responsestatus_code = response.status_codeif status_code == 200: print("API connection successful")else: print("API connection failed")
------------------------------
Andrea Paviglianiti
------------------------------