by xavdid · 3y ago · 0 comments
import json
import urllib3
http = urllib3.PoolManager()
data = {'key': 'value'}
encoded_data = json.dumps(data).encode('utf-8')
r = http.request(
'POST',
'http://httpbin.org/post',
body=encoded_data,
headers={'Content-Type': 'application/json'}
)
in requests, it's: import requests
requests.post('http://httpbin.org/post', json={'key': 'value'}) import urllib3
urllib3.request("POST", "https://httpbin.org/post", json={"key": "value"})Yes, I just didn't in my toy example. That's the response object, which will typically include all the response info, plus reponse.request, which has request info.
> and does it give you the same information to help debug that http.request gives?
I'm not positive, but I'd bet it's similar.