Skip to content

RestTemplate should encode the url variables [SPR-5516] #10187

Closed
@spring-projects-issues

Description

@spring-projects-issues

Tareq Abedrabbo opened SPR-5516 and commented

The RestTemplate does not encode the url variables. The following line:

template.postForLocation("http://twitter.com/statuses/update.xml?status={status}", "", "Ho Ho");

Results in an exception:

Exception in thread "main" java.lang.IllegalArgumentException
	at java.net.URI.create(URI.java:842)
	at org.springframework.web.util.UriTemplate.expand(UriTemplate.java:140)
	at org.springframework.web.client.core.RestTemplate.execute(RestTemplate.java:266)
	at org.springframework.web.client.core.RestTemplate.postForLocation(RestTemplate.java:203)
	at test.RestClientTest.main(RestClientTest.java:30)
Caused by: java.net.URISyntaxException: Illegal character in query at index 48: http://twitter.com/statuses/update.xml?status=Ho Ho
	at java.net.URI$Parser.fail(URI.java:2809)
	at java.net.URI$Parser.checkChars(URI.java:2982)
	at java.net.URI$Parser.parseHierarchical(URI.java:3072)
	at java.net.URI$Parser.parse(URI.java:3014)
	at java.net.URI.<init>(URI.java:578)
	at java.net.URI.create(URI.java:840)
	... 4 more

Affects: 3.0 M2

Issue Links:

0 votes, 5 watchers

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)type: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions