#!/usr/bin/env python import json import requests def main(): headers = {"Content-Length": "234"} print('-' * 50) print(requests.post( "http://localhost:2000/asdf", data={'foo': 'bar', 'num': 2}, headers=headers).content.decode()) print('-' * 50) print(requests.post( "http://localhost:2000/asdf", data=json.dumps({'foo': 'bar', 'num': 2}, separators=(',', ':')), headers=headers).content.decode()) if __name__ == '__main__': main()