Announcement Announcement Module
Collapse
No announcement yet.
no suitable HttpMessageConverter found for request type Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    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

    Comment


    • #3
      @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

      Comment


      • #4
        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

        Comment


        • #5
          yeah..i saw the thread..its initial post

          Comment

          Working...
          X