dougp
dougp

Reputation: 3089

Accessing users' My Content through the Cognos Analytics REST API

Using the Cognos Analytics 11.2.4FP4 REST API

As an Cognos Analytics administrator, I want to be able to gather information about the contents of users' My Content for both management purposes and to be able to help the users. It would be good to be able to identify a user from an error or warning message in a log file (so, CAMID), as well as by name, and be able to open their My Content folder.

As an administrator, I can open any user's My Content folder in the UI by forming a URL like this:

https://{servername}/ibmcognos/bi/?perspective=content&tab=myContent&folder={storeId}

(...because I am using SSO through IIS. Directly against the dispatcher looks like it will also work: https://{servername}:9300/bi/?perspective=content&tab=myContent&folder={storeId} )

I'm writing PowerShell scripts to access Cognos content through the REST API. I want to be able to copy a CAMID value from cognosserver.log and open a user's My Content folder.

Using the REST API to navigate to content is something like this:

Get the top-level content objects...

$uri = "$uriBase/api/v1/content"
$content = Invoke-RestMethod -Uri $uri -Method Get -Headers $headers -contentType $contentType -WebSession $Session
$content.content | Format-Table -Property defaultName, id
defaultName  id
-----------  --
Team Folders team_folders
My Folders   my_folders
Library      library

...then navigate into the folder you want by using the id returned by the REST API, which is the StoreID...

$uri = "$uriBase/api/v1/content/team_folders/items"
$content = Invoke-RestMethod -Uri $uri -Method Get -Headers $headers -contentType $contentType -WebSession $Session
$content.content | Format-Table -Property defaultName, id
defaultName                          id
-----------                          --
Calendars                            i8A1504F64F5B46B2AB59830B9C404BEB
Samples                              iAB158D0F0A6846BAA6E995C096DCBCD8
Get started                          iDC73F9D7F95944939457D8C17A648B3C
Templates                            iB1369136802C4135B2BC5244E46EDD3D
The Weather Company, an IBM Business iBFA319BAE60746A3838EACD5E48D4F1C

But this doesn't appear to be possible when starting from an account:

$uri = "$uriBase/api/v1/users?identifier=$userCAMID"
$account = Invoke-RestMethod -Uri $uri -Method Get -Headers $headers -contentType $contentType -WebSession $Session
$account.users
modificationTime : 8/19/2024 3:27:29 PM
id               : xV1NET1RBRDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
type             : user
defaultName      : Aaaaaaa, Aaaaaaa
email            : [email protected]
searchPath       : CAMID("DIRNS:u:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
tenantID         : 
version          : 160
links            : {@{rel=self; type=application/json; href=/api/v1/users/xV1NET1RBRDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}}

A StoreID is 33 characters beginning with "i".
The id value for an account object is 57 characters beginning with "xV1NET1RBRD", so it is clearly not a StoreID

So...

$uri = "$uriBase/api/v1/content/$($account.users.id)/items"
$content = Invoke-RestMethod -Uri $uri -Method Get -Headers $headers -contentType $contentType -WebSession $Session

...doesn't work because the request needs a StoreID like...

/api/v1/content/{storeid}/items

I can see that each account has a StoreID in the Content Store database. So I know it exists, but I'm not seeing how to get it from the REST API.

How can I get the StoreID of an account from the REST API? (and, of course, I'm hoping that will work when making the call to "content", which may not be true)
Alternatively, and more generically, how can I use the REST API to get to a specific user's My Content folder, or at least retrieve the StoreID of the user's My Content folder?

Upvotes: 0

Views: 91

Answers (0)

Related Questions