python request post with json with headers

Solutions on MaxInterview for python request post with json with headers by the best coders in the world

showing results for - "python request post with json with headers"
Julieta
14 Oct 2017
1url = "http://localhost:8080"
2data = {'sender': 'Alice', 'receiver': 'Bob', 'message': 'We did it!'}
3headers = {'Content-type': 'application/json', 'Accept': 'text/plain'}
4r = requests.post(url, data=json.dumps(data), headers=headers)
5