Are you aware of httr::with_verbose() that will let you see the HTTP request as its made? Thats helpful for debugging at least.
With that you could write the HTTP to a file with capture.output()
library(httr)
capture.output(
with_verbose(POST(url = "http://httpbin.org/post",
body = "foo",
content_type("application/json"))
), type = "message")
Gives:
Response [http://httpbin.org/post]
Date: 2017-12-08 10:32
Status: 200
Content-Type: application/json
Size: 463 B
{
"args": {},
"data": "foo",
"files": {},
"form": {},
"headers": {
"Accept": "application/json, text/xml, application/xml, */*",
"Accept-Encoding": "gzip, deflate",
"Connection": "close",
"Content-Length": "3",
...
[1] "-> POST /post HTTP/1.1\r"
[2] "-> Host: httpbin.org\r"
[3] "-> User-Agent: libcurl/7.54.0 r-curl/3.0 httr/1.3.1\r"
[4] "-> Accept-Encoding: gzip, deflate\r"
[5] "-> Accept: application/json, text/xml, application/xml, */*\r"
[6] "-> Content-Type: application/json\r"
[7] "-> Content-Length: 3\r"
[8] "-> \r"
[9] ">> foo"
[10] "<- HTTP/1.1 200 OK\r"
[11] "<- Connection: keep-alive\r"
[12] "<- Server: meinheld/0.6.1\r"
[13] "<- Date: Fri, 08 Dec 2017 10:32:45 GMT\r"
[14] "<- Content-Type: application/json\r"
[15] "<- Access-Control-Allow-Origin: *\r"
[16] "<- Access-Control-Allow-Credentials: true\r"
[17] "<- X-Powered-By: Flask\r"
[18] "<- X-Processed-Time: 0.000996112823486\r"
[19] "<- Content-Length: 463\r"
[20] "<- Via: 1.1 vegur\r"
[21] "<- \r"