Invalid www-form encoding on query-string, got pla%nning

Please i have issue with query params but can seems to get this fixed.

I have a url just like this http://localhost:4000/api/search/review?keyword=pla%nning

And i get

Plug.Conn.InvalidQueryError at GET /api/search/review
invalid www-form encoding on query-string, got pla%nning

action looks like this

def index(conn, %{"keyword" => keyword}) do
    IO.inspect keyword
end

Elixir 1.4.4 and Phoenix 1.2

Please what best approach can i use to resolve this.

How do you generate the url? Using the phoenix helper?

Maybe have a look at your browser developer tools for that request. A screenshot of that would be cool :slight_smile:

Thanks @h4cc.

I use bloodhound engine and the snippet is similar to below

  
          remoteHost = "http://localhost:4000/api/search/review";
            template = Handlebars.compile($("#result-template").html());
            empty = Handlebars.compile($("#empty-template").html());

            engine = new Bloodhound({
                identify: function(o) { return o.id_str; },
                queryTokenizer: Bloodhound.tokenizers.whitespace,
                datumTokenizer: Bloodhound.tokenizers.obj.whitespace('name'),
                dupDetector: function(a, b) { return a.id_str === b.id_str; },
                prefetch: {
                    url: remoteHost +'?prefetch',
                    cache: false
                },
                remote: {
                    url: remoteHost + '?keyword=%QUERY',
                    wildcard: '%QUERY',
                    cache: false
                }
            });

Please also find attached the screenshot

I have a url just like this
http://localhost:4000/api/search/review?keyword=pla%nning

…which is not a valid URL query string.

Please see RFC 3986 - Uniform Resource Identifier (URI): Generic Syntax

HTH!

2 Likes

Just what I was going to reference. The escape code of %nn is entirely not a valid URL escape so I’m not sure what was expected to happen?