json post python with headers

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

showing results for - "json post python with headers"
Hugo
05 Jun 2019
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