python post json - fourslick/notes GitHub Wiki

y = {
    "type":"cetak_struk_pendapatan",
    "data":data_response
}
jsonData = json.dumps(y)
print(jsonData)
url = "http://localhost:8080/prints"
headers = {'Content-type': 'application/json', 'Accept': 'text/plain'}
r = requests.post(url, data=jsonData, headers=headers)
print("Status code: ", r.status_code)
print("Printing Entire Post Request")
print(r.content)