Search code examples
restpowershellsystem.net.httpwebrequest

View Raw Xml of System.Net.HttPWebRequest in PowerShell


All,

I am trying to access a restful API via PowerShell. The API requires several non-standard headers so I am using the $request.Headers.Add() syntax.

I am getting a (500) Internal Server error so I know I am nowhere close.

I can't use WireShark because the endpoint is Https.

How can I build a HttpWebRequest object in PowerShell and view the Raw XML?

Here is the simple code:

$concat = EncodeBase64("$($username)@$($org):$($password)")

$request = [System.Net.HttpWebRequest]::Create($URL);
$request.Method = "POST";
$request.ContentType = "application/vnd.vmware.vcloud.session+xml;version1.5";
$request.Headers.Add("x-vcloud-authorization", $concat);

Thanks!


Solution

  • Go grab Fiddler and read up on how to use it to view https traffic.