How to url encode User Search Query Syntax for Management API in Python

I am trying to url encode this query string:

email:john*

and after quoting the string using Python urllib.parse.quote() my final URL looks like this:

https://{domain}/api/v2/users?q=email%3Ajohn%2A

but the search doesn’t work because urllib.parse.quote() is also quoting the * which isn’t supposed to be quoted according to the List or search users documentation.

How to quote the query string so that the wildcards are not quoted?

Hi @_resun,

Welcome to the Auth0 Community!

You should use the optional safe parameter in the urllib.parse.quote() function to specify additional ASCII characters that should not be quoted. (Reference: urllib.parse — Parse URLs into components — Python 3.12.1 documentation)

For example:
urllib.parse.quote("https//{domain}/api/v2/users?q=email:john*", safe='*')

Let me know if there’s anything else I can do to help.

Thanks,
Rueben

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.