How can I log the full XMLHTTP request and response when I encounter a VBA Error 400, including headers?

Responsive Ad Header

Question

Grade: Education Subject: Support
How can I log the full XMLHTTP request and response when I encounter a VBA Error 400, including headers?
Asked by:
104 Viewed 104 Answers
Responsive Ad After Question

Answer (104)

Best Answer
(478)
Use these steps: 1) Log the request URL. 2) Log all request headers using `XMLHTTP.getAllResponseHeaders`. 3) Log the request body (if applicable). 4) Log the HTTP status code (`XMLHTTP.Status`). 5) Log the response headers (using `XMLHTTP.getAllResponseHeaders` again after the request is sent). 6) Log the response body (`XMLHTTP.responseText`). Write this information to a file or a database table for later analysis. Libraries like `FileSystemObject` help with file writing.