Results 1 to 4 of 4

Thread: PUT requests failing from RestTemplate to Roo generate JSON restful web service

  1. #1
    Join Date
    Jul 2008
    Posts
    13

    Default PUT requests failing from RestTemplate to Roo generate JSON restful web service

    I've built a very simple restful JSON web service using the Roo shell that comes with STS Version: 3.0.0.201208090952-RELEASE.

    I've configured a client using the RestTemplate with a MappingJacksonHttpMessageConverter and this is working nicely for GETs, POSTs and DELETEs.

    The issue I'm hitting is with PUT operations, they do not supply a "ReponseType" to the HttpEntityRequestCallback and so default "Accept" headers are used for the the PUT request.

    Alas the MVC Web + JSON web service I built with Roo then routes the call to the HTML controller and not the JSON controller.

    As Roo is in charge of the controllers I am relying on the request mappings to "just work".

    • Should I be trying to force the RestTemplate to set "Accept: application/json" for PUTs? (If so, how?)
    • Has Roo got the controller request mapping wrong? It is currently set to "@RequestMapping(method = RequestMethod.PUT, headers = "Accept=application/json")" for the json controller.
    • Or maybe its just me that's at fault ...


    Any advice welcome!
    Thanks.

  2. #2
    Join Date
    Jul 2008
    Posts
    13

    Default

    Just to add ... PUTs via Curl are working fine.

  3. #3
    Join Date
    Jul 2008
    Posts
    13

    Default

    I've solved the issue by using an alternative PUT method in the rest template which allows me to override the "accept" header by passing in an HttpEntity.

    ttfn.

  4. #4
    Join Date
    Jun 2008
    Location
    Philadelphia, PA, USA
    Posts
    212

    Default

    Can you add a JIRA issue for this as a bug in the REST support?
    Ken Rimple
    Chariot Solutions
    email: krimple@chariotsolutions.com
    work: www.chariotsolutions.com/education
    personal: www.rimple.com

    Author: Spring Roo in Action (Manning)
    MEAP Site: manning.com/rimple

Posting Permissions

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