ahmadnassri/httpsnippet

View on GitHub
src/targets/python/python3/fixtures/application-json.py

Summary

Maintainability
A
3 hrs
Test Coverage
import http.client

conn = http.client.HTTPConnection("mockbin.com")

payload = "{\"number\":1,\"string\":\"f\\\"oo\",\"arr\":[1,2,3],\"nested\":{\"a\":\"b\"},\"arr_mix\":[1,\"a\",{\"arr_mix_nested\":{}}],\"boolean\":false}"

headers = { 'content-type': "application/json" }

conn.request("POST", "/har", payload, headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))