Hi Carmen,
On Mar 31, 2009, at 11:43 PM, Carmen Delessio wrote:
> I've hit the same issue and wanted to provide a specific scenario.
> I am using the Jersey Client to talk directly to the Facebook Rest
> server.
>
> It working well, but some Facebook requests take JSONArrays as
> paramaters.
>
> This is an example of what is expected as a Facebook parameter
> "images":[{ "src":"http:\/\/www.facebook.com\/images\/image1.gif",
> "href":"http:\/\/www.facebook.com" }]
>
> My code looks something like:
>
> UriBuilder ub =UriBuilder.fromPath(
> facebookRestServer);
> ...
> ub.queryParam("template_data", stringWithCurlyBrackets);
> URI uri = ub.build();
> resource = restClient.resource(uri);
> restResponse =resource.get(ClientResponse.class);
>
> A workaround would be great and if I'm going in the wrong direction,
> please let me know.
>
> I've tried to work around this by replacing { with %7b, but that led
> to some issues with Facebook signatures. I will continue on that path.
>
That is what i was going to recommend, percent encode the '{' and '}'
as they are not valid characters in the URI (and strictly speaking it
is the same for the '[' and ']' characters) .
String e = UriComponent.contextualEncode(
stringWithCurlyBrackets,
UriComponent.Type.QUERY_PARAM,
false);
ub.queryParam("template_data", e);
The problem is quite fundamental because:
URI u = URI.create("
http://localhost:8080/path?a={curly}");
results in an illegal argument exception so to use the client API it
is necessary to percent encode the curlies.
Paul.