I need to support OR statement in REST API, and I don't know how to build right query string. Maybe, something like this?
or maybe standard solution exists?
According to the W3C (and they are the official source on these things), a space character in the query string (and in the query string only) may be encoded as either " %20 " or " + ".
On the internet, a Query string is the part of a link (otherwise known as a hyperlink or a uniform resource locator, URL for short) which assigns values to specified attributes (known as keys or parameters). Typical link containing a query string is as follows: http://example.com/over/there?
To add a parameter to the URL, add a /#/? to the end, followed by the parameter name, an equal sign (=), and the value of the parameter. You can add multiple parameters by including an ampersand (&) between each one.
The %27 is ASCII for the single quote ( ' ) and that is a red flag for someone trying to perform SQL injection via the query string to your application's data access layer logic.
Option 1: You can have a string that represents all of the values. and in code, you'll break the string apart according to some delimiter.
key=val1,val2,val3
and lets say (in pseudo code): var vals = explode( GETPARAMS['key'] , ',' )
Option 2: You can use array notation in your url arguments:
key[0]=val1&key[1]=val2&key[2]=val3
and in code, the value of key
will be an array: array( val1, val2, val3 )
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With