when I am specifying responseType in axios config in react I am getting 401 from Azure Ad authr service, I wanted the responseType to be specified as the response i am getting from the api is of FileContentResult, I am expecting for it to be readable as an arrayBuffer, any suggestion here why is this failing for Azure authentication.
API Code:
async Task<dynamic> ExportExcel()
{
byte[] FileContent = null;
FileContent = abc.GenerateExcel(_configuration, data);
return File(
FileContent,
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
"abc.xls");
}
UI:
export async function DownloadExcel(Token) {
const config = {
headers: {
Authorization: `Bearer ${Token}`,
'Content-Type': 'blob',
}
}
const AxiosRequestConfig = {method: 'POST', url: `APIURL/Controller/ExportExcel`, responseType: 'arraybuffer', config};
const response = await axios(AxiosRequestConfig);
return response.data;
}