<p dir="auto"><strong><a href="https://jira.spring.io/secure/ViewProfile.jspa?name=tareq" rel="nofollow">Tareq Abedrabbo</a></strong> opened <strong><a href="https://jira.spring.io/browse/SPR-5516?redirect=false" rel="nofollow">SPR-5516</a></strong> and commented</p>
<p dir="auto">The RestTemplate does not encode the url variables. The following line:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="template.postForLocation(&quot;http://twitter.com/statuses/update.xml?status={status}&quot;, &quot;&quot;, &quot;Ho Ho&quot;);"><pre class="notranslate"><code class="notranslate">template.postForLocation("http://twitter.com/statuses/update.xml?status={status}", "", "Ho Ho");
</code></pre></div>
<p dir="auto">Results in an exception:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Exception in thread &quot;main&quot; 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.&lt;init&gt;(URI.java:578)
	at java.net.URI.create(URI.java:840)
	... 4 more"><pre class="notranslate"><code class="notranslate">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.&lt;init&gt;(URI.java:578)
	at java.net.URI.create(URI.java:840)
	... 4 more
</code></pre></div>
<hr>
<p dir="auto"><strong>Affects:</strong> 3.0 M2</p>
<p dir="auto"><strong>Issue Links:</strong></p>
<ul dir="auto">
<li><a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="398168568" data-permission-text="Title is private" data-url="https://github.com/spring-projects/spring-framework/issues/16441" data-hovercard-type="issue" data-hovercard-url="/spring-projects/spring-framework/issues/16441/hovercard" href="https://github.com/spring-projects/spring-framework/issues/16441">#16441</a> Unable to retrieve FlashMap when contains "+"(half-space) in the request parameters</li>
<li><a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="398098787" data-permission-text="Title is private" data-url="https://github.com/spring-projects/spring-framework/issues/10957" data-hovercard-type="issue" data-hovercard-url="/spring-projects/spring-framework/issues/10957/hovercard" href="https://github.com/spring-projects/spring-framework/issues/10957">#10957</a> UrlPathHelper is too aggressive decoding URLs</li>
<li><a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="398098829" data-permission-text="Title is private" data-url="https://github.com/spring-projects/spring-framework/issues/10962" data-hovercard-type="issue" data-hovercard-url="/spring-projects/spring-framework/issues/10962/hovercard" href="https://github.com/spring-projects/spring-framework/issues/10962">#10962</a> Spring:url tag should not use application/x-www-form-urlencoded encoding</li>
</ul>
<p dir="auto">0 votes, 5 watchers</p>
<p dir="auto"><strong><a href="https://jira.spring.io/secure/ViewProfile.jspa?name=arielkung" rel="nofollow">ArielS</a></strong> opened <strong><a href="https://jira.spring.io/browse/SPR-7037?redirect=false" rel="nofollow">SPR-7037</a></strong> and commented</p>
<p dir="auto">Hi,<br>
I have the same problem that you resolved in the following issue for the put method:</p>
<p dir="auto"><a href="http://jira.springframework.org/browse/SPR-5836" rel="nofollow">http://jira.springframework.org/browse/SPR-5836</a></p>
<p dir="auto">Right now i'm subclassing RestTemplate but i have to add AcceptHeaderRequestCallback and PostPutCallback inner classes because they are private members of the parent class.</p>
<hr>
<p dir="auto"><strong>Issue Links:</strong></p>
<ul dir="auto">
<li><a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="398159425" data-permission-text="Title is private" data-url="https://github.com/spring-projects/spring-framework/issues/15256" data-hovercard-type="issue" data-hovercard-url="/spring-projects/spring-framework/issues/15256/hovercard" href="https://github.com/spring-projects/spring-framework/issues/15256">#15256</a> Please add a putForEntity and a putForLocation method to RestTemplate (<em><strong>"duplicates"</strong></em>)</li>
</ul>
<p dir="auto">2 votes, 2 watchers</p>