Uploaded image for project: 'Spring Framework'
  1. Spring Framework
  2. SPR-8016

RestTemplate - support response mapping to entity with potentially empty response body.

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Complete
    • Affects Version/s: 3.1 M1
    • Fix Version/s: 4.1.5, 4.2 RC1
    • Component/s: Web
    • Labels:
      None
    • Last commented by a User:
      false

      Description

      I am working with an API which returns an empty response body on http status 200 (OK) & a body which is populated on http status 400 (Bad Request).

      When using RestTemplate.getForEntity() this is fine for the case where the body is populated, however I get an exception for the 'null body' case.

      My understanding is one should provide a class implementing the ResponseBody interface & make the call via the execute() method on the RestTemplate.

      This task is a request to consider that the use case here is common & whether Spring should offer something out of the box for this situation.

      Also See: http://stackoverflow.com/questions/3322381/spring-resttemplate-behavior-when-handling-responses-with-a-status-of-no-content/3648447#3648447

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                bclozel Brian Clozel
                Reporter:
                dvb123 David Victor
                Last updater:
                Brian Clozel
              • Votes:
                9 Vote for this issue
                Watchers:
                19 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Days since last comment:
                  3 years, 10 weeks ago