Last active
July 7, 2021 06:51
-
-
Save thepacketgeek/6691361 to your computer and use it in GitHub Desktop.
POST JSON from Python with Requests
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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