-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Description
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
A payload within a GET request message has no defined semantics;
sending a payload body on a GET request might cause some existing
implementations to reject the request.
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.