Skip to content

Add String based URI template variants to RequestEntity [SPR-17551] #22083

@spring-projects-issues

Description

@spring-projects-issues

Ryon Day opened SPR-17551 and commented

The RestTemplateBuilder documentation for the rootUri() method states:

"Set a root URL that should be applied to each request that starts with '/'."

However, the following code does not result in RestTemplate expanding the URI:

UriTemplate template = new UriTemplate("/foo?bar={bar}");

this.restTemplate = restTemplateBuilder
 .rootUri(URI.create("http://foo.bar"))
 .build();

URI uri = template.expand("baz");
RequestEntity<Void> req = RequestEntity.get(uri)
 .accept(MediaType.APPLICATION_JSON)
 .header(accountLinkHeader, accountLinksHeader)
 .build();
String response = restTemplate.exchange(req, String.class);

 

Moreover, the exception received is EXTREMELY ambiguous when this doesn't work. In fact, the Spring exception thrown occludes the initial Apache exception (which states there's no host).


Affects: 5.1.3

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)status: supersededAn issue that has been superseded by anothertype: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions