Grazie, @u235 effettivamente sto leggendo solo ora i tuoi messaggi, non avevo ricevuto neanche la notifica via email.
Ho provato con un tool come PostMan, l'errore viene visualizzato correttamente, forse c'è qualcosa da modificare lato client come chiamo il metodo....
Posto il codice della chiamata:
codice:
$.ajax({ type: "POST",
url: url_with_params,
headers: {
'Authorization': 'Bearer ' + sessionStorage.getItem(JWTTokenName),
'Content-Type': "application/json;charset=UTF-8"
},
// Seems like the only way to get access to the xhr object
xhr: function () {
var xhr = new XMLHttpRequest();
xhr.responseType = 'blob'
return xhr;
},
data: jsonData,
cache: true,
success: function (data, status, xhr) {
var blob = new Blob([data], { type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" });
var downloadUrl = URL.createObjectURL(blob);
//Get fileName
var headers = xhr.getAllResponseHeaders();
var arr = headers.trim().split(/[\r\n]+/);
// Create a map of header names to values
var headerMap = {};
arr.forEach(function (line) {
var parts = line.split(': ');
var header = parts.shift();
var value = parts.join(': ');
headerMap[header] = value;
});
var fileName = headerMap["content-disposition"];
var a = document.createElement("a");
a.href = downloadUrl;
a.download = fileName;
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
},
error: function (err, type, httpStatus) {
var failureMessage = 'Error occurred in ajax call ' + err.status + " - " + err.responseText + " - " + httpStatus;
console.log(failureMessage);
}
});