I have been tasked with writing a certain Powershell script into Go. I do not believe I am at liberty to share many of the details of what this script needs to do, except this: the script makes a call to an API using Invoke-WebRequest
. The request is a GET
request with a JWT for authorization.
This request succeeds in Powershell but fails in Go due to some firewall issue. For some reason, the request is blocked when sent from Go but has no issues when sent from Powershell. There is a proxy, and that proxy is built into the Go http
client. I have been able to build and successfully use clients with this proxy in Go in this environment before. The Powershell request does not involve passing credentials to the proxy.
My hope is that by reviewing the request constructed by Go and comparing it against the request generated by Invoke-WebRequest
, I can identify what is missing from the Go request and make corrections accordingly. Currently, I can review the raw request in Go with httputil.DumpRequestOut()
, but I cannot find how to capture the raw request created and sent by Invoke-WebRequest
in Powershell. At least, I cannot find a way that satisfies the constraints of my situation.
I have seen solutions that involve the use of Fiddler, netsh
, and wireshark, but unfortunately I do not have any access to these tools in my environment. These all require elevated rights that I do not possess, and that I will not be granted. I have attempted to review the source code of Invoke-WebRequest
itself but have not found any help there either. I encountered a link to the Fiddler repo, which was encouraging, but the post with the link was seven years old and the repo no longer exists there.
Unless I am severely mistaken, the request must be constructed locally before it is sent, so there must be some way for one to access the request locally. How might I access the raw request generated by Invoke-WebRequest
?