Announcement Announcement Module
No announcement yet.
Send JSON data via HTTP POST using spring android Page Title Module
Move Remove Collapse
This topic is closed
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Send JSON data via HTTP POST using spring android

    I am using spring android framework for retrieving json data via Http POST. The parameters which are sent to Server via http body; got null.

    ResponseEntity<LoginBean> responseEntity =, HttpMethod.POST, requestEntity, LoginBean.class);
    While calling this method; in requestEntity both http header and body are found but when actually call is made to the server(via Spring API) the parameters are found null at server end.

    The code for bean is as follow :
    public class LoginBean {
    private String status;
    public String getStatus() {
    	return status;
    public void setStatus(String status) {
    	this.status = status;
    Android code is as follow :
    protected String doInBackground(String... params) {
    String username = params[0];
    String password = params[1];
    String url = connectServices.connectLoginServiceURL();
    MultiValueMap<String, String> loginServiceParam = new LinkedMultiValueMap<String, String>();
    loginServiceParam.add("username", username);
    loginServiceParam.add("password", password);
    HttpHeaders requestHeaders = new HttpHeaders();
    HttpEntity<MultiValueMap<String, String>> requestEntity = new HttpEntity<MultiValueMap<String, String>>(loginServiceParam, requestHeaders);
    // Create a new RestTemplate instance
    RestTemplate restTemplate = new RestTemplate();
    // Add the Gson message converters
    restTemplate.getMessageConverters().add(new GsonHttpMessageConverter());
    restTemplate.getMessageConverters().add(new StringHttpMessageConverter());
    // Make the HTTP POST request, marshaling the response from JSON
    ResponseEntity<LoginBean> responseEntity =, HttpMethod.POST, requestEntity, LoginBean.class);
    LoginBean loginBeanResponse = responseEntity.getBody();
    status = loginBeanResponse.getStatus();
    return status;
    Please suggest some solution.
    Last edited by arpit88dawda; Feb 21st, 2013, 12:30 AM.