У меня есть конечная точка отдыха, которая принимает RequestParam и RequestBody в качестве параметра. На стороне клиента я использую клиент javax для вызова этой конечной точки отдыха, но получаю проблему, так как код ответа 405. приходит с сервера.
Вот код SpringBoot restEndpoint:
@RequestMapping(value = "/run", method = RequestMethod.POST, consumes = "application/json")
public ReportRunResult runBackendCall(@RequestParam(name = "clientName", required = true) String reportName,
@RequestBody Map<String, ReportParameter> formParams) {
return service.runReport(reportName, formParams);
}
вот как я вызываю эту конечную точку с клиента:
public ReportRunResult runBackendCall(String name, Map<String, ReportParameter> parameters) {
ReportRunResult reportResponse = null;
WebTarget target = RestClientBuilder.clientBuilder(RestClientBuilder.buildSSLContext(), 3000, 10000).build()
.target(serverURL.get() + "/run?reportName=" + name);
Invocation.Builder invocationBuilder = target.request(MediaType.APPLICATION_JSON_TYPE);
Response response = target.request(MediaType.APPLICATION_JSON_TYPE).post(Entity.json(parameters));
reportResponse = response.readEntity(ReportRunResult.class);
log.info("response. " + response.getStatus() + " ");
}
Я не понимаю, почему сервер отправляет ответ 405 Нужно ли конвертировать Map (параметры) в строку json в Entity.json (параметры));