-
May 14th, 2010, 06:18 AM
#1
Escaping '&' in args of restTemplate.getForObject
Hi there,
I'm having trouble when I use '&' in a args parameter for restTemplate.getForObject. The RestTemplate seems to think it is another parameter in the url and thus cuts the String I'm posting from the '&'.
Here is my example:
Map<String, String> vars = new HashMap<String, String>();
vars.put(CommonWebConstants.RPXSocialNetworking.AP I_KEY,"xxxxxxxxx")
vars.put(CommonWebConstants.RPXSocialNetworking.ID ENTIFIER,"http://www.facebook.com/profile.php?id=xxxxxx");
vars.put(CommonWebConstants.RPXSocialNetworking.ST ATUS, "trying to escape & so doesn't cut off post");
String result = restTemplate.getForObject("https://myurl.com/api/v2/set_status?apiKey={apiKey}&identifier={identifier} &status={status}",String.class, vars);
My problem is with the status.. this could be any text typed by the user and may include '&' in the text. The result of this is 'trying to escape '. It sees the '&' as a new parameter and truncates the rest. I have tried escaping the '&' with & and %26 but these just print out.
Please help!!
Thanks,
Ali
-
May 18th, 2010, 06:32 AM
#2
Resolved
I've now resolved this issue by using the getForObject method that takes a URI - this one doesn't do any encoding and so I can encode the text myself and handles the ampersand.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules