You have to pass the Accept
header. This has been discussed many times before.
solved thank you very much
It works on local:3000 but when I use ReverseProxyInboundRule , It does not work on my main domain.
My script:
const response = await fetch(`/api/reports/route?${query.toString()}`, {
headers: { Accept: 'application/json', 'Content-Type': 'application/json' },
});
My java code:
@Path("route")
@GET
public Collection<Position> getRoute(
@QueryParam("deviceId") List<Long> deviceIds,
@QueryParam("groupId") List<Long> groupIds,
@QueryParam("from") Date from,
@QueryParam("to") Date to) throws StorageException {
permissionsService.checkRestriction(getUserId(), UserRestrictions::getDisableReports);
LogAction.logReport(getUserId(), "route", from, to, deviceIds, groupIds);
return routeReportProvider.getObjects(getUserId(), deviceIds, groupIds, from, to);
}
const response = await fetch(`/api/reports/route?${query.toString()}`, {
headers: { Accept: 'application/json', 'Content-Type': 'application/json; charset=utf-8' },
});
Finally it works. add 'Content-Type': 'application/json; charset=utf-8' to your angular project
I am calling the following endpoint
and the response brings me an xlsx file, unlike the other endpoints