Home > Blockchain >  Request Post URL is not working with Django
Request Post URL is not working with Django

Time:01-19

I have tried requests.post in Django but it was not working. It was fine with request.get.

headers = {'Content-type': 'application/json'}
answer = requests.post('http://www.testing/getdata', data = {'testing': 'testing'}, verify=False,auth=(testing,testing),headers=headers)

Results:

"Unexpected Error Occurred:RESTEASY008200: JSON Binding deserialization error"

CodePudding user response:

You sent form data, but you set headers like you sent json.

I guess you wanna do something like that:

headers = {'Content-type': 'application/json'}
answer = requests.post('http://www.testing/getdata', json = {'testing': 'testing'}, verify=False,auth=(testing,testing),headers=headers)
  •  Tags:  
  • Related