title: rest POST object using spring for android
body: <p>I'm trying to POST to a rest service using spring for android(I'm new at this)</p>
  
  <p>The restful service has this structure</p>
  
  <pre><code>@POST
  @Path("/ider")
  @Consumes(MediaType.APPLICATION_JSON)
  @Produces(MediaType.APPLICATION_JSON)
  public SearchOutRO hashTrackInJSON(SearchInRO in);
  </code></pre>
  
  <p>with(shortened object code):</p>
  
  <pre><code>public class SearchInRO implements Serializable {
      private Double latitud;
      private Double longitud;
  }
  
  public class SearchOutRO implements Serializable {
      private Integer searchId;
  }
  </code></pre>
  
  <p>so I'm trying this(from android)</p>
  
  <pre><code>String url = BASE_URL + "ider";
  HttpHeaders requestHeaders = new HttpHeaders();
  
  requestHeaders.setContentType(MediaType.APPLICATION_JSON);
  
  MultiValueMap&lt;String, String&gt; body = new LinkedMultiValueMap&lt;String, String&gt;();
  body.add("searchInRO[latitud]", String.valueOf(user.getLatitud()));
  body.add("searchInRO[longitud]", String.valueOf(user.getLongitud()));
  
  HttpEntity&lt;?&gt; requestEntity = new HttpEntity&lt;Object&gt;(body, requestHeaders);
  RestTemplate restTemplate = new RestTemplate();
  
  List&lt;HttpMessageConverter&lt;?&gt;&gt; messageConverters = new ArrayList&lt;HttpMessageConverter&lt;?&gt;&gt;();
  messageConverters.add(new FormHttpMessageConverter());
  messageConverters.add(new StringHttpMessageConverter());
  restTemplate.setMessageConverters(messageConverters);
  try {
      ResponseEntity&lt;SearchOutRO&gt; response = restTemplate.exchange(url, HttpMethod.POST, requestEntity, SearchOutRO.class);
  
      HttpStatus status = response.getStatusCode();
      if (status == HttpStatus.CREATED) {
          return true;
      } else {
          return false;
      }
  } catch (Exception e) {
      e.printStackTrace();
      return false;
  }
  </code></pre>
  
  <p>and getting this exception:</p>
  
  <pre><code>org.springframework.web.client.RestClientException: Could not write request: no suitable HttpMessageConverter found for request type [org.springframework.util.LinkedMultiValueMap] and content type [application/json]
  </code></pre>
  
  <p>Could you help me pointing out what am I doing wrong?(and how make it right).<br>
  I think it may the the "body" MultiValueMap.</p>
  
  <p>Thanks in advance</p>
  
  <p><strong>EDIT:</strong>  I tried what @Krisl suggested. I succeed to connect to the server side, but it seems the object is not correctly marshalled. </p>
  
  <pre><code>WARNING: javax.xml.bind.UnmarshalException
   - with linked exception:
  [javax.xml.bind.UnmarshalException: unexpected element (uri:"", local:"latitud"). Expected elements are &lt;{}searchInRO&gt;]
  </code></pre>
  
  <p>I would appreciate any ideas. </p>