I need to download a file from a different server (from Documentum) through a VBCS application. If i put the URL of the document into postman and provide basic authentication and then click on send and download, I am able to download the document but when i try to do it through AJAX and javascript, the document does not get downloaded but i can see the contents of the document in the response of my GET call. Following is the code that i have written -
var xhrdoc = new XMLHttpRequest();
xhrdoc.open("GET", docURL1);
xhrdoc.setRequestHeader("Accept", "*/*");
// xhrdoc.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
xhrdoc.setRequestHeader("Content-Type","application/octet-stream");
xhrdoc.setRequestHeader("Content-Disposition", "attachment");
xhrdoc.setRequestHeader("Authorization","Basic "+btoa(username+":"+password));
console.log("Log:docURL",xhrdoc.status);
// window.location.href = docURL1;
xhrdoc.send();
xhrdoc.onload = function () {
console.log("inside onload for get doc");
console.log("Log: inside getdoc",xhrdoc.status, "Status");
console.log("Log: inside getdoc",xhrdoc.responseURL,"ResponseURL");
console.log("Log inside get doc response text",xhrdoc.responseText);
console.log("log inside response ", xhrdoc.response);
Any help will be really appreciated. Thank you!