Skip to content

Instantly share code, notes, and snippets.

@claudiobusatto
Created August 24, 2019 14:10
Show Gist options
  • Save claudiobusatto/747ef5b0e47978a5505ee2fa30636c7e to your computer and use it in GitHub Desktop.
Save claudiobusatto/747ef5b0e47978a5505ee2fa30636c7e to your computer and use it in GitHub Desktop.
POST request with JSON body in Python using requests library
import requests
import json
url = "http://localhost:8080"
data = {'key': 'value'}
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