Answer the question
In order to leave comments, you need to log in
Why 500 error when post request to server on Spring?
Please tell me why the error org.springframework.web.client.HttpServerErrorException: 500 appears when a post request is received, while the get request is processed normally (on the client it is written in the same way as post, only the getForObject method is used). The client is on android, the server is made using Spring mvc. What is wrong?
Customer:
public class postFinder extends AsyncTask<Void, Void, String> {
@Override
protected String doInBackground(Void... voids) {
RestTemplate restTemplate = new RestTemplate();
restTemplate.getMessageConverters().add(new MappingJackson2HttpMessageConverter());
String id = restTemplate.postForObject(Constans.GET_MY_ID, ServisConnecter.id, String.class);
return id;
}
}
@RestController
@RequestMapping("/remind")
public class MyController {
String ip;
@Autowired
public AdressServiceInterf adressServiceInterf;
@RequestMapping(value = "get", method = RequestMethod.GET)
@ResponseBody
public long getUserId(HttpServletRequest request){
ip=getClientIpAddr(request);
return createMockAdresses(ip);
}
@RequestMapping(value = "getrand", method = RequestMethod.POST)
@ResponseBody
public String getRandomAdress(@RequestBody Long id){
return "my id = " + id;
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question