The result of the CreateReport method is a binary byte-stream where the PDF or Excel report are returned directly. The calling application will have to handle the response and present and/or save the binary output.
Identify the latest downloaded file from the downloads folder and then open in a browser by using
window.open method in Javascript..
Cheers,
Srikanth Dasari
Alternatively, you can use the blob type with your esriRequest like this (it will download the file and the user can click to open in browser):
esriRequest({
handleAs: 'blob',
content: myArgs,
url: 'https://geoenrich.arcgis.com/arcgis/rest/services/World/geoenrichmentserver/geoenrichment/createrepo...'
}).then(function(response) {
if (response instanceof Blob) {
var blob = new Blob([response], { type: 'application/pdf' });
if (navigator.msSaveBlob) { // IE 10+
navigator.msSaveBlob(blob, 'myfile.pdf');
} else {
var link = document.createElement("a");
var url = URL.createObjectURL(blob);
link.setAttribute("href", url);
if (link.download !== undefined) { // feature detection
// Browsers that support HTML5 download attribute
link.setAttribute("download", this.fileName);
}
link.style = "visibility:hidden";
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
}
}
});