请求 Post URL 不适用于 Django
Request Post URL is not working with Django
我在 Django 中尝试过 requests.post,但它没有用。 request.get.
没问题
headers = {'Content-type': 'application/json'}
answer = requests.post('http://www.testing/getdata', data = {'testing': 'testing'}, verify=False,auth=(testing,testing),headers=headers)
结果:
"Unexpected Error Occurred:RESTEASY008200: JSON Binding deserialization error"
您发送了表单数据,但您设置 headers 就像您发送 json 一样。
我猜你想做这样的事情:
headers = {'Content-type': 'application/json'}
answer = requests.post('http://www.testing/getdata', json = {'testing': 'testing'}, verify=False,auth=(testing,testing),headers=headers)
我在 Django 中尝试过 requests.post,但它没有用。 request.get.
没问题headers = {'Content-type': 'application/json'}
answer = requests.post('http://www.testing/getdata', data = {'testing': 'testing'}, verify=False,auth=(testing,testing),headers=headers)
结果:
"Unexpected Error Occurred:RESTEASY008200: JSON Binding deserialization error"
您发送了表单数据,但您设置 headers 就像您发送 json 一样。
我猜你想做这样的事情:
headers = {'Content-type': 'application/json'}
answer = requests.post('http://www.testing/getdata', json = {'testing': 'testing'}, verify=False,auth=(testing,testing),headers=headers)