Skip to content
This repository was archived by the owner on Feb 26, 2023. It is now read-only.
This repository was archived by the owner on Feb 26, 2023. It is now read-only.

@Rest doesn't encode all parameters #1677

Description

@jpelgrom

When using a @Rest interface with a method that takes URL parameters, such as:

@Get("/search/keyword/{keyword}/mode/{mode}")
public SearchResponse search(String keyword, String mode);

Using any characters that are considered safe for use in URLs, such as / and &, these characters will not be encoded. For example, search("any/key", "alpha") will result in the following URL:

/search/keyword/any/key/mode/alpha

Which obviously will result in an error, because now the parameters are "any" and "mode". Expected behaviour: the URL parameters are escaped, like this:

/search/keyword/any%2Fkey/mode/alpha

Encoding the parameter in my own code doesn't solve this issue, because %2F wil be encoded in to %252F. Changing the input from String to android.net.Uri or java.net.URI to prevent encoding also doesn't make any difference. Using the Spring RestTemplate, you could just pass an UriTemplate to prevent encoding, but that doesn't seem to be possible here.

Is it possible to either force it to encode everything in the parameter, as I'd expect, or force it not to encode anything, so that the user would have to encode it?

Using AA 3.3.2 and Spring Android REST template 2.0.0M3

Activity

  1. WonderCsabo commented on Jan 12, 2016

    @WonderCsabo
    Member

    In AA 4.0, we added the @Path annotation which is mandatory for path parameters. It does not support encoding yet, but we plan to add a parameter to encode the url variable, just like Retrofit does.

  2. gauravsak commented on Dec 30, 2016

    @gauravsak

    @WonderCsabo I think your answer seems enough. Should this issue be closed then? Thanks!

  3. WonderCsabo commented on Dec 30, 2016

    @WonderCsabo
    Member

    @gauravsak we should add encoding parameters in the future.

  4. Mehly commented on Feb 6, 2017

    @Mehly

    Is there anything new on this issue/feature? Any plans on when this feature is going to be released?

  5. WonderCsabo commented on Feb 6, 2017

    @WonderCsabo
    Member

    We have limited time to develop new features, contributions are always welcomed and get reviewed quickly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions