Endpoint api/reports/route

Felipe2 years ago

I am calling the following endpoint

https://demo2.traccar.org/api/reports/route?deviceId=3861&from=2022-11-21T00:00:00Z&to=2022-11-28T00:00:00Z

and the response brings me an xlsx file, unlike the other endpoints

Anton Tananaev2 years ago

You have to pass the Accept header. This has been discussed many times before.

Felipe2 years ago

solved thank you very much

MDAa year ago

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);
}
MDAa year ago
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