Skip to content

Instantly share code, notes, and snippets.

@thepacketgeek
Last active July 7, 2021 06:51
Show Gist options
  • Save thepacketgeek/6691361 to your computer and use it in GitHub Desktop.
Save thepacketgeek/6691361 to your computer and use it in GitHub Desktop.
POST JSON from Python with Requests
import requests
url = "http://localhost:8080"
data = {'sender': 'Alice', 'receiver': 'Bob', 'message': 'We did it!'}
headers = {'Content-type': 'application/json', 'Accept': 'text/plain'}
r = requests.post(url, data=json.dumps(data), headers=headers)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment