MetaManager - Administrative Tools for IBM Cognos
Pricing starting at $2,100
Download Now Learn More
Quote from: dougp on 30 Oct 2024 01:51:14 PMI have been trying to leverage the Cognos Analytics REST API from PowerShell and have had some success. But now I'd like to use it in the context of Cognos Analytics as a JavaScript-based extension.
If I'm logging in directly through the dispatcher (https://servername:9300/), I can run this script to return a list of data modules.// get base URI from Cognos
const origin = document.location.origin;
// Use this for connecting directly to the dispatcher
//const port = "9300";
const uriBase = origin; //+ ":" + port;
// // Use this for SSO
// const port = "9300";
// const uriBase = origin + ":" + port;
// URI to retrieve all data modules
const uri = uriBase + "/api/v1/modules";
// set the request method
const method = 'GET';
// set the content type
const contentType = "application/json; charset=utf-8";
// inspect the site's cookies to get the XSRF token
const a = document.cookie.split(";");
let b = "";
a.forEach((e) => { if (e.startsWith("XSRF-TOKEN=")) b = e;});
const XSRFTOKEN = b.replace("XSRF-TOKEN=", "");
// set the headers and options for the fetch
const headers = {
'x-xsrf-token': XSRFTOKEN,
accept: 'application/json',
'Cache-Control': 'no-cache',
'Content-Type': contentType
}
const requestOptions = {
method: method,
headers: headers
}
// finally, make the call
let output = await fetch (uri, requestOptions)
.then(response => {
if (!response.ok) {
throw new Error('Network response was not ok');
}
return response.json();
})
.then(data => {
return data;
})
.catch(error => {
console.error('Error:', error);
});
console.log(JSON.stringify(output, null, 2));
But if I log in using single sign-on through IIS (https://servername/ibmcognos), and slightly modify my code (see inline comments), it doesn't work.Access to fetch at 'https://servername:9300/api/v1/modules' from origin 'https://servername' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
Thinking that the Cognos Analytics Firewall may help, I added servername and servername:9300 to the list. No love.
I have also tried setting either header.mode = 'no-cors' or requestOptions.mode = 'no-cors'.
What changes are needed to use the Cognos Analytics REST API while using single sign-on on IIS?
// get base URI from Cognos
const origin = document.location.origin;
// Use this for connecting directly to the dispatcher
//const port = "9300";
const uriBase = origin; //+ ":" + port;
// // Use this for SSO
// const port = "9300";
// const uriBase = origin + ":" + port;
// URI to retrieve all data modules
const uri = uriBase + "/api/v1/modules";
// set the request method
const method = 'GET';
// set the content type
const contentType = "application/json; charset=utf-8";
// inspect the site's cookies to get the XSRF token
const a = document.cookie.split(";");
let b = "";
a.forEach((e) => { if (e.startsWith("XSRF-TOKEN=")) b = e;});
const XSRFTOKEN = b.replace("XSRF-TOKEN=", "");
// set the headers and options for the fetch
const headers = {
'x-xsrf-token': XSRFTOKEN,
accept: 'application/json',
'Cache-Control': 'no-cache',
'Content-Type': contentType
}
const requestOptions = {
method: method,
headers: headers
}
// finally, make the call
let output = await fetch (uri, requestOptions)
.then(response => {
if (!response.ok) {
throw new Error('Network response was not ok');
}
return response.json();
})
.then(data => {
return data;
})
.catch(error => {
console.error('Error:', error);
});
console.log(JSON.stringify(output, null, 2));
Access to fetch at 'https://servername:9300/api/v1/modules' from origin 'https://servername' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
Quote from: Lokesh Reddy on 29 Oct 2024 10:01:03 AMHi Mark,
Thank You for your response.
Could you please let me know from where we can set the decimal precision to a lower number, whether it can be set on Report settings or Cognos Server or SQL Database?
Thanks,
Lokeswara
Quote from: Lokesh Reddy on 28 Oct 2024 11:43:31 PMHi,
We are getting below error on Cognos while running one report in background.
"PDS-PPE-0104 A record was rejected. An arithmetic overflow occurred. -1,379,278,883 DMB-ECB-0070 PPDS Error."
Could you please suggest where and what might be the issue/root cause for this error and how to get rid of this error.
Thanks,
Lokeswara
BSP Software Documentation |
MetaManager Documentation and Knowledgebase |
Version Control Documentation and Knowledgebase |
BSP Software | Resources | About Us | ||
MetaManager | BSP Software Training | BSP Software | ||
Integrated Control Suite | YouTube Channel | Micro Strategies Inc | ||
Security Migration | IBM Cognos | |||
Integrated Management Suite | ||||