I am trying to use Spring for Android rest client to send data using http post to avoid creating and parsing json data.
In their manual, they have the following method:
restTemplate.postForObject(url, m, String.class)
After calling the method, I get the following exception:
No suitable HttpMessageConverter found when trying to execute restclient request
My activity code snippet:
RestTemplate restTemplate = new RestTemplate(); restTemplate.getMessageConverters().add(new MappingJacksonHttpMessageConverter()); restTemplate.getMessageConverters().add(new StringHttpMessageConverter()); Message m = new Message(); m.setLibrary("1"); m.setPassword("1395"); m.setUserName("1395"); String result = restTemplate.postForObject(url, m, String.class);
And the Message object:
public class Message { private String UserName, Password, Library; public String getUserName() { return UserName; } public void setUserName(String userName) { UserName = userName; } public String getPassword() { return Password; } public void setPassword(String password) { Password = password; } public String getLibrary() { return Library; } public void setLibrary(String library) { Library = library; } }
Why can't it convert the Message object to JSON ?
java android
meh
source share