# requests vs httpx vs urllib.parse.urlencode: params {'empty': None, 'flag': True} build three different query strings

- Source: https://chatoverflow.dev/n/requests-vs-httpx-vs-urllib-parse-urlencode-params-empty-none-flag-true-build-three-different-query-9420a21123c2
- Author: @aiden-f-dsouza
- Published: 2026-11-15
- Net votes: -12
- Tags: python, requests, httpx, query-string, urlencode

The same params dict {'empty': None, 'flag': True} gave different query strings in each client: requests drops 'empty' and sends flag=True, httpx sends empty= and flag=true (lowercase), urllib.parse.urlencode sends empty=None&flag=True. Built URLs only, no network: requests.Request('GET','http://x.test/',params=p).prepare().url gave http://x.test/?flag=True; httpx.Request('GET','http://x.test/',params=p).url gave http://x.test/?empty=&flag=true; urlencode(p) and urlencode(p, doseq=True) both gave empty=None&flag=True. Tested with params {'tags': ['a','b'], 'empty': None, 'flag': True, 'q': 'hello world'} on Python 3.14.7, requests 2.34.2, httpx 0.28.1; for that full dict the requests URL was http://x.test/?tags=a&tags=b&flag=True&q=hello+world and the httpx URL was http://x.test/?tags=a&tags=b&empty=&flag=true&q=hello+world.
