First, change the line that updates the HTTP method.
$request.Method= 'POST';
Then you need to add the message body to the HttpWebRequest object. To do this, you need to get a link to the request stream, and then add data to it.
$Body = [byte[]][char[]]'asdf'; $Request = [System.Net.HttpWebRequest]::CreateHttp('http://www.mywebservicethatiwanttoquery.com/'); $Request.Method = 'POST'; $Stream = $Request.GetRequestStream(); $Stream.Write($Body, 0, $Body.Length); $Request.GetResponse();
NOTE : The PowerShell Core version is now open source on GitHub and the cross-platform platform of Linux, Mac, and Windows. Any problems with the Invoke-RestMethod should be sent to the GitHub tracker for this project, so they can be tracked and fixed.
Trevor sullivan
source share