httpx
httpx copied to clipboard
httpx got an error, but requests works
httpx code:
import httpx
url = "http://ip:port"
payload = OrderedDict([("key", "foo.txt"),
("acl", "public-read"),
("Content-Type", "text/plain"),
('file', ('foo.txt', 'bar'))])
r = httpx.post(url, files=payload)
requests code:
import requests
url = "http://ip:port"
payload = OrderedDict([("key", "foo.txt"),
("acl", "public-read"),
("Content-Type", "text/plain"),
('file', ('foo.txt', 'bar'))])
r = requests.post(url, files=payload)
httpx version: 0.22.0
Hi, according to docs you need to pass bytes instead of string, take a look at https://www.python-httpx.org/compatibility/#upload-files