1
I’m having a problem with my Rest requests.
Until a while ago my code was working normally, but one to two weeks ago, my requests stopped working, except for GET and Delete methods
GET
@RequestMapping(value = "/api/estabelecimentos", method = RequestMethod.GET, produces = "application/json")
public @ResponseBody List<Estabelecimento> getAllEst() {
return er.findAll();
}
Delete
@RequestMapping(method = RequestMethod.DELETE, value = "/api/estabelecimentos/{id}", produces = "application/json")
public ResponseEntity<Estabelecimento> deleteEst(@PathVariable Long id) {
er.deleteById(id);
return new ResponseEntity<Estabelecimento>(HttpStatus.OK);
}
The other methods (POST and PUT) return error 415 via client (Postman) and in the springboot log I get this return;
POST
@RequestMapping(method = RequestMethod.POST, value = "/api/estabelecimentos", produces = "application/json")
public ResponseEntity<Estabelecimento> newEstabelecimento(@RequestBody Estabelecimento estabelecimento) {
er.save(estabelecimento);
return new ResponseEntity<Estabelecimento>(estabelecimento, HttpStatus.OK);
}
PUT
@RequestMapping(method = RequestMethod.PUT, value = "/api/estabelecimentos/{id}", produces = "application/json")
public ResponseEntity<Object> updadeEstabelecimento(@RequestBody Estabelecimento esta, @PathVariable Long id){
Optional<Estabelecimento> estab = er.findById(id);
if(!estab.isPresent())
return ResponseEntity.notFound().build();
esta.setCod_Estabelecimento(id);
er.save(esta);
return ResponseEntity.noContent().build();
}
Log Springboot
14:24:36.716 WARN 14320 --- [nio-8080-exec-1] .c.j.MappingJackson2HttpMessageConverter : Failed to evaluate Jackson deserialization for type [[simple type, class com.api.Entity.Estabelecimento]]: com.fasterxml.jackson.databind.JsonMappingException: Multiple back-reference properties with name 'defaultReference'
2019-05-22 14:24:36.720 WARN 14320 --- [nio-8080-exec-1] .c.j.MappingJackson2HttpMessageConverter : Failed to evaluate Jackson deserialization for type [[simple type, class com.api.Entity.Estabelecimento]]: com.fasterxml.jackson.databind.JsonMappingException: Multiple back-reference properties with name 'defaultReference'
2019-05-22 14:24:36.724 WARN 14320 --- [nio-8080-exec-1] .w.s.m.s.DefaultHandlerExceptionResolver : Resolved [org.springframework.web.HttpMediaTypeNotSupportedException: Content type 'application/json;charset=UTF-8' not supported]
Retorno Clien(Postman)
"timestamp": "2019-05-22T17:24:36.740+0000",
"status": 415,
"error": "Unsupported Media Type",
"message": "Content type 'application/json;charset=UTF-8' not supported",
"trace": "org.springframework.web.HttpMediaTypeNotSupportedException: Content type 'application/json;charset=UTF-8' not supported\r\n\tat org.springframework.web.servlet.mvc.method.annotation.AbstractMessageConverterMethodArgumentResolver.readWithMessageConverters(AbstractMessageConverterMethodArgumentResolver.java:224)\r\n\tat org.springframework.web.servlet.mvc.method.annotation.RequestResponseBodyMethodProcessor.readWithMessageConverters(RequestResponseBodyMethodProcessor.java:157)\r\n\tat org.springframework.web.servlet.mvc.method.annotation.RequestResponseBodyMethodProcessor.resolveArgument(RequestResponseBodyMethodProcessor.java:130)\r\n\tat org.springframework.web.method.support.HandlerMethodArgumentResolverComposite.resolveArgumen
Can anyone give me a light ? I couldn’t find anything on the internet
Send the Requisition Body and send the entity Establishment tbm
– Isaías de Lima Coelho
one to two weeks ago, my requests stop working - What change have you made in these two weeks to stop working?
– nullptr
Could post the Establishment entities and their sub-entities that are like attributes, because this error should be some cyclical reference, where the father calls the son, who then the son calls the parent or the child has more than one parent
– Weslley Barbosa