Strange problems with the Spring RestTemplate in Android application
- by HarryCater
I begin to use RESTful api of the Spring Framework in my android client application. But I have encountered with problems when I tried to execute HTTP request via postForObject/postForEntity methods. Here is my code:
public String _URL = "https://noticemed.com/app/mobile/login";
public void  BeginAuthorization(View view)
{     
        HttpHeaders requestHeaders = new HttpHeaders();
        requestHeaders.setContentType(MediaType.APPLICATION_JSON);
         HttpEntity<String> _entity = new HttpEntity<String>(requestHeaders);
        RestTemplate templ = new RestTemplate();
        templ.setRequestFactory(new HttpComponentsClientHttpRequestFactory());
        templ.getMessageConverters().add(new MappingJacksonHttpMessageConverter());
        ResponseEntity<String> _response = templ.postForEntity(_URL,_entity,String.class); //HERE APP CRASHES
        String _body = _response.getBody();
And here is a stack trace in logcat after app crashing.
As you see there is no definite error message. So the question what am I doing wrong? How to fix this? May there is other way to do it?I really need a help. Thanks in advance!