3

I am having a rest API where end point is like this:

/private/items/query

where I am taking id as query param so url is like:

http://localhost:8081/private/items/query?id=item1234

Now when the item contains % symbol its not reaching as query param in my APIs properly e.g. in case of item%21 what I am receiving is item!.

How can this problem be fixed?

0

1 Answer 1

5

The % symbol is generally used to encode special characters in query string e.g. + is encoded to %2B while sending as query string.

As mentioned [here][1]:

Because the percent ("%") character serves as the indicator for percent-encoded octets, it must be percent-encoded as "%25" for that octet to be used as data within a URI.

In your case you need to send %2521 which will be decoded to %21 at the backend as %25 is % when url-decoded. You can use this [link][2] for url-encoding purpose. [1]: https://www.rfc-editor.org/rfc/rfc3986#section-2.4 [2]: https://www.urlencoder.org/

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.