Hi all, I`m looking for a general solution regarding getting document content with the rest-api or other. I`m presently building an angular application that will be used for interacting with content server 10.5 rest api to deliver business fuctions regarting the management of doucments. The app is currently able to: auth/ get nodes / get details / delete nodes / get versions / upload documents but I'm struggling to get the {server-info}/llisapi.dll/api/v1/nodes/{id}/conent or {server-info}/llisapi.dll/api/v1/nodes/{id}/versions/{number}/conent calls to work. I'm are receiving a CORS isssue on the OPTIONS call throug all browsers but when testing with Postman to ensure the cla is appropriate the results are positive and the call in successfull. At this point I'm looking for suggestion of to troubleshoot the server confiration or an alternative implementation. One alternative I was thinking of is to simply generate the link to the document on the page but unfortunatly in this scenario the user need to authenticate a sconde time as I was not able to use the rest-api tokent to authenticate the user... Any help would be grately appreciated. CHeers!
Example Code:
Conponent - Call
// method to get the documents file content
public getDocumentContent(id: number, version: number = -1): void {
// here we define the appropriate rest api call url
let url = `${this.baseUrl}nodes/${id}/`;
if (version === -1) {
url += `content`;
} else {
url += `versions/${version}/content`;
}
// LLCookie ???
const options = new RequestOptions();
this.setHttpHeaderToken(options);
this.endpoint.download2(url, options).then(resolve => {
console.log('getDocumentContent - resolve', resolve);
}, reject => {
console.log('getDocumentContent - reject', reject);
});
}
OP - Service
public download (url: string, options?: RequestOptions): Promise<any> {
return new Promise((resolve, reject) => {
const xhr: XMLHttpRequest = new XMLHttpRequest();
xhr.onreadystatechange = () => {
if (xhr.readyState === 4) {
if (xhr.status === 200) {
resolve(xhr);
} else {
reject(xhr);
}
}
};
xhr.open('GET', url, true);
xhr.withCredentials = true;
xhr.responseType = 'arraybuffer';
if (options !== undefined) {
options.headers.keys().forEach(hKey => {
xhr.setRequestHeader(hKey, options.headers.get(hKey));
});
}
xhr.send(null);
Results:
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at {My Server}/llisapi.dll/api/v1/nodes/631829/content. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing).