Am I able to log out the URL and headers that the ...
# troubleshooting
t
Am I able to log out the URL and headers that the rest tap is about to use before it sends out the request?
v
Could you give some more context?
t
I'm using the tap-rest-api-msdk and I would like to see the URL it's calling and the headers it's passing
Setting the log level to debug doesn't show it. I think at this point I need to clone the repo, add some logging, then load it into my meltano project manually
With my current yaml I'm getting a 400 back from the api. That's hard to troubleshoot without knowing what request I'm sending
c
There is some commented out code in the tap_rest_api-msdk/streams.py files that can be uncommented to print debug messages. Do note that though by default it logs to std out so will break the stream. I often replace it with the following to avoid that. It will print sensitive headers etc so beware how/where you use it
Copy code
# Remove commented section to show http_request for debugging
import logging
import http.client

http.client.HTTPConnection.debuglevel = 1

logging.basicConfig()
logging.getLogger().setLevel(logging.DEBUG)
requests_log = logging.getLogger("requests.packages.urllib3")
requests_log.setLevel(logging.DEBUG)
requests_log.propagate = True

def print_to_log(*args):
    requests_log.debug(" ".join(args))

http.client.print = print_to_log