Not sure which forum this belongs in, but has anyone successfully implemented a GET /users call using the Cognos 11.1.7 REST API? I am trying to use the call to return the ID of a user, but I can't figure out what the call wants. According to the documentation, it wants a parameter of:
identifier (string(query))
Unique id from Cognos Access Manager Identifier or CAMID of the user. I.e., if a user's CAMID value is CAMID("APPID:u:jdoe@ibm.com"), the value of identifier is jdoe@ibm
Is this a URL parameter sent with a question mark? Is this a body param? I have tried many variations an nothing has worked. I have to assume it is a URL param, when I don't sent it as such I get a 400 and "may not be null". But it doesn't like anything I send it.
In the process, all I have is the user name. I need to call this to get the user ID to send to other endpoints.
Thanks!
After trial and error, I found that if I send /users?identifier=<namespace> will return all users in the namespace. I can work with that.
Quote from: patternghost on 27 May 2021 09:56:54 AM
After trial and error, I found that if I send /users?identifier=<namespace> will return all users in the namespace. I can work with that.
Hi, I am tying to do the same but actually haven't got session yet to pass the authentication using the format which IBM suggests. Could you share how you did that? Thanks.
https://www.ibm.com/docs/en/cognos-analytics/11.1.0?topic=apis-rest-api
You certainly can use the credentials method as specified for 11.2.4, however I found the CAMAPI method as documented for 12 does function for 11.2.4 and is much easier to use. You'll have to create an API key for the user within the Cognos interface. Logged into Cognos as the user, at the top right click the account profile icon, then click 'profile and settings'. From there click the 'manage' link next to 'My API keys'. Here you can create your API key, don't lose it or you'll have to create a new one.
12 Documentation (https://www.ibm.com/docs/en/cognos-analytics/12.0.0?topic=api-getting-started-rest)
Here is a super simple proof of concept in powershell (I'm forced to use powershell, please... someone help me...)
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
# Define authentication parameters
$authParams = @{
parameters = @(
@{
name = "CAMAPILoginKey"
value = "YourKeyHere"
}
)
}
# Convert the authentication parameters to JSON
$authParamsJson = $authParams | ConvertTo-Json
# Send the PUT request to authenticate
$auth = Invoke-RestMethod -Method PUT -Uri 'http://yourCognosURL.com:9300/api/v1/session' -Body $authParamsJson -ContentType 'application/json' -UseBasicParsing
# Define headers
$headers = @{
'accept' = 'application/json'
'IBM-BA-Authorization' = $auth.session_key
'Cache-Control' = 'no-cache'
}
# Send the GET request to the /api/v1/session endpoint
Invoke-RestMethod -Method GET -Uri 'http://yourCognosURL.com:9300/api/v1/session' -Headers $headers -UseBasicParsing
If you want to use credentials you sure can, but you need to know your CAMNamespace name as shown in the Cognos Administration Console application (cogstart.xml) on the server itself. Here is the authparams structure that you could drop in replace to the previous code example:
# Define authentication parameters
$authParams = @{
parameters = @(
@{
name = "CAMNamespace"
value = "yourNamespace.com"
},
@{
name = "CAMUsername"
value = "yourUsername"
},
@{
name = "CAMPassword"
value = "yourPassword"
}
)
}
I hope that helps! Now if only I could figure out how to do the auth using the DataDirect Autonomous REST connector... I'm close... I can feel it.