Results 1 to 5 of 5

Thread: no suitable HttpMessageConverter found for request type

  1. #1
    Join Date
    Jun 2011
    Posts
    2

    Post no suitable HttpMessageConverter found for request type

    Hi All,

    When i invoke the postForObject () method i got exception in my android application.

    My code is:

    String url = "http://localhost:8080/rest/login";

    Sample sam = new Sample ();
    sam.setUserID("User1");
    sam.setPassword("password");

    RestTemplate restTemplate = new RestTemplate(new CommonsClientHttpRequestFactory());

    ResponseType ms = new ResponseType ();

    ms = restTemplate.postForObject(url, mp, MySession.class); ---> when the control comes here i got below exception..


    Caused by: org.springframework.web.client.RestClientException : Could not write request: no suitable HttpMessageConverter found for request type [Sample ]


    Please help me to solve the above problem.

    Thanks in advance,
    Kumaresan

  2. #2
    Join Date
    Nov 2010
    Posts
    175

    Default

    Hi Kumaresan, what kind of content type is the rest/login endpoint expecting? If you are trying to convert JSON, are you including the Jackson library in your classpath? I recommend looking at the Spring Android Showcase, as it has some examples of using the different message converters available in Rest Template.

    -Roy
    Roy Clarkson
    Spring Mobile Projects Lead

  3. #3
    Join Date
    Jun 2011
    Posts
    2

    Default

    @Path("/login")
    @Service
    @Scope("request")
    public class login {

    @POST
    @Produces("application/json")
    public Response Login(Sample Sample) {

    ResponseSession ResponseSession= loginService.DoIt(Sample);
    return Response.ok(ResponseSession).build();
    }
    }

    the above code is my server side login method here Sample is a java pojo class ...

    now i want to call this REST service in android client using POST.

    pls help me in how to send the object Sample from Android client

  4. #4

    Default

    Take a look at the thread: "Examples to make RestTemplate work with JSON?" in this forum. It was one of the first posts in this forum, it will be a page or two back.

    Perry

  5. #5
    Join Date
    Sep 2011
    Posts
    2

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •