Skip to content

RestTemplate - support response mapping to entity with potentially empty response body. [SPR-8016] #12671

Closed
@spring-projects-issues

Description

@spring-projects-issues

David Victor opened SPR-8016* and commented

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


Affects: 3.1 M1

Issue Links:

9 votes, 19 watchers

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions