Invoke-WebRequest using Get method doesn't allow content-body #2054
Labels
Issue-Enhancement
the issue is more of a feature request than a bug
Resolution-External
The issue is caused by external component(s).
WG-Cmdlets
general cmdlet issues
Making a HTTP GET requests using either Invoke-WebRequest or Invoke-RestMethod with a content-body throws an exception. HTTP RFC 7231 describes that a content-body is allowed even though the response of the webserver might be
This is making it difficult to interface with various RESTful API's like InfoBlox and ElasticSearch that rely on JSON payloads for retrieving data.
Steps to reproduce
$uri = 'http://www.microsoft.com'
$payload = @{Microsoft='loves linux'}
$result = Invoke-WebRequest -Uri $uri -Body ($payload | ConvertTo-Json) -ContentType 'application/json' -Method Get
Expected behavior
HTTP OK
Actual behavior
Invoke-WebRequest : Cannot send a content-body with this verb-type.
The text was updated successfully, but these errors were encountered: