Can I include multiple "where" clauses (or an AND operator) in an endpoint query string? I'd like to do something like this:
http://localhost:5000/regions?where=name=="El Salvador"&where=lang=="es"
I've tried few different syntaxes, but I can't get it to work.
Is this possible? I know I can do it using MongoDB syntax, but I would like to use Python syntax.
Note: I'm not trying to concatenate an list of parameteres using python, I'm trying to use Eve's filtering feature using native python syntax.
URL parameters are made of a key and a value, separated by an equal sign (=). Multiple parameters are each then separated by an ampersand (&).
A query string is a part of a uniform resource locator (URL) that assigns values to specified parameters.
To send parameters in URL, write all parameter key:value pairs to a dictionary and send them as params argument to any of the GET, POST, PUT, HEAD, DELETE or OPTIONS request. then https://somewebsite.com/?param1=value1¶m2=value2 would be our final url.
QueryString. Query Strings are also generated by form submission or can be used by a user typing a query into the address bar of the browsers. Query Strings are contained in request headers. A Query String collection is a parsed version of the QUERY_STRING variable in the Server Variables collection.
Have you tried http://localhost:5000/regions?where=name=="El Salvador"%20and%20lang=="es"
?
You can replace %20
for space
in the URL
if it doesn't work. In my postman environment works both ways.
Seems to work like the AND
you want. The documentation mentions it, but it misses an example I think. Mind the correct position for double quotes.
Querystring Array Parameters in Python using Requests
Looks like what you are after. The where clause is not necessary if you are using the '&' syntax so your clause should look something like this
http://localhost:5000/regions?name=='El Salvador'&lang=='es'
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