Cannot make URL query string with a parameter without a value
See original GitHub issueURL query string may contain a parameter, which has no value i.e. http://host/path/?foo or http://host/path/?a=1&foo. Currently Requests does not provide support for that.
In [68]: d
Out[68]: {'a': 1, 'foo': None}
In [69]: tl
Out[69]: [('a', 1), ('foo',)]
In [70]: RequestEncodingMixin._encode_params(d)
Out[70]: 'a=1'
In [71]: RequestEncodingMixin._encode_params(tl)
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-71-5d4dac855108> in <module>()
----> 1 RequestEncodingMixin._encode_params(tl)
/home/f557010/jpm/local/lib/python2.7/site-packages/requests/models.pyc in _encode_params(data)
87 elif hasattr(data, '__iter__'):
88 result = []
---> 89 for k, vs in to_key_val_list(data):
90 if isinstance(vs, basestring) or not hasattr(vs, '__iter__'):
91 vs = [vs]
ValueError: need more than 1 value to unpack
Expected:
'a=1&foo'
Issue Analytics
- State:
- Created 8 years ago
- Reactions:4
- Comments:34 (14 by maintainers)
Top Results From Across the Web
Is a url query parameter valid if it has no value? - Stack Overflow
Although it is recognized that the query string will often carry name-value pairs, it is not required to (e.g. it will often contain...
Read more >Handling query string parameters with no value in ASP.NET ...
So, let's see what we can do about it! By default, a boolean parameter is bound using SimpleTypeModelBinder , which is used for...
Read more >URLSearchParams - Web APIs - MDN Web Docs
Chrome Edge
URLSearchParams Full support. Chrome49. Toggle history Full support. Edge...
@@iterator Full support. Chrome49. Toggle history Full support. Edge...
URLSearchParams() constructor Full support. Chrome49. Toggle...
Read more >URL query string parameters in list and workflow criteria
Query string parameters are added to your website URLs when you use tracking URLs to track a visit from a certain source and...
Read more >How to Use Query Strings and Parameters for Marketers
While adding multiple values or symbols in your query string, you need to encode them correctly in order for your query string to...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
in 3.0, i think we can consider making emptry string not result in an =
It’s not the same as having a parameter without a value. Yours renders the = sign after the parameter name. Some applications will work, but as a matter of providing a complete solution this exact case should be addressed. That urllib doesn’t do it is of no significance. Requests does many things better than standard libraries for HTTP - that is its reason to exist.