How to send a request with multiple cookies (list of dictionaries)? #2176
Answered
by
simon-liebehenschel
simon-liebehenschel
asked this question in
Q&A
-
ProblemPassing multiple cookies is not documented. This is an expected (desirable) behavior that does not work:cookies = [
{
"name": "foo",
"value": "bar",
},
{
"name": "spam",
"value": "eggs",
},
]
r = httpx.get("https://my-website.org/", cookies=cookies)Sadly, 'httpx' does not support passing a list of dictionaries out of the box. |
Beta Was this translation helpful? Give feedback.
Answered by
simon-liebehenschel
Apr 12, 2022
Replies: 1 comment
-
|
Found in docs: >>> cookies = httpx.Cookies()
>>> cookies.set('cookie_on_domain', 'hello, there!', domain='httpbin.org')
>>> cookies.set('cookie_off_domain', 'nope.', domain='example.org')
>>> r = httpx.get('http://httpbin.org/cookies', cookies=cookies)
>>> r.json()
{'cookies': {'cookie_on_domain': 'hello, there!'}} |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
simon-liebehenschel
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Found in docs: