最佳答案
What is the difference between the data and json parameters in the python Requests package?
It is unclear from the documentation
Does this code:
import requests
import json
d = {'a': 1}
response = requests.post(url, data=json.dumps(d))
Note that we convert the dict
to JSON here ☝️ !
Do anything different than:
import requests
import json
d = {'a': 1}
response = requests.post(url, json=d)
If so, what? Does the latter automatically set the content-type
in the header to application/json
?