1

I'm having some problems with a webresource. I want to pass encoded parameter to my request. Thing is that when I use URLEncoder.encode, it encoded well my param, but when I execute the request jersey will encode it again.

If I pass my param without encoding before, jersey will not encode it.

This is weird. Any solutions?

here some of my code :

WebResource webResource = this.resource(this.myURL, login, password);
        webResource.addFilter(new com.sun.jersey.api.client.filter.LoggingFilter());

        String paramEncoded = URLEncoder.encode(param);

        try {
            certificateTool.disableSslChecks();
            userInfosAccessRights = webResource.path("getInfos").
                queryParam("id", paramEncoded).
                get(MyClass.class);
        } catch (UniformInterfaceException exc) {

param is : tvR1AwZ/4YrsCp0TKV3/od+tHeMeB/u8Y68cPpAEwoM= encoded param : tvR1AwZ%2F4YrsCp0TKV3%2Fod%2BtHeMeB%2Fu8Y68cPpAEwoM%3D

param in the request : tvR1AwZ%252F4YrsCp0TKV3%252Fod%252BtHeMeB%252Fu8Y68cPpAEwoM%253D

Thanks

user1687267
  • 43
  • 1
  • 5

1 Answers1

2

When you send the parameter as a query parameter it follows the rules for encoding as per the specification. These rules are different from those for encoding URLs, which is why you are seeing different results. Jersey is doing the correct thing and you should not encode the parameter prior to passing it to queryParam()