Skip to content

Instantly share code, notes, and snippets.

@peterjpxie
Last active November 21, 2020 19:36
Show Gist options
  • Save peterjpxie/8f81653a55e21c8600400f15ffea5625 to your computer and use it in GitHub Desktop.
Save peterjpxie/8f81653a55e21c8600400f15ffea5625 to your computer and use it in GitHub Desktop.
REST API logging example
# pytest -sv
test_post_headers_body_json_pprint.py::test_post_headers_body_json
-----------Request----------->
POST https://httpbin.org/post
User-Agent: python-requests/2.22.0
Accept-Encoding: gzip, deflate
Accept: */*
Connection: keep-alive
Content-Length: 39
{
"key1": 1,
"key2": "value2"
}
<-----------Response-----------
Status code:200
Access-Control-Allow-Credentials: true
Access-Control-Allow-Origin: *
Content-Encoding: gzip
Content-Type: application/json
Date: Thu, 11 Jul 2019 06:20:34 GMT
Referrer-Policy: no-referrer-when-downgrade
Server: nginx
X-Content-Type-Options: nosniff
X-Frame-Options: DENY
X-XSS-Protection: 1; mode=block
Content-Length: 264
Connection: keep-alive
{
"args": {},
"data": "{\n \"key1\": 1,\n \"key2\": \"value2\"\n}",
"files": {},
"form": {},
"headers": {
"Accept": "*/*",
"Accept-Encoding": "gzip, deflate",
"Content-Length": "39",
"Host": "httpbin.org",
"User-Agent": "python-requests/2.22.0"
},
"json": {
"key1": 1,
"key2": "value2"
},
"origin": "103.115.210.48, 103.115.210.48",
"url": "https://httpbin.org/post"
}
PASSED
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment