Home Dashboard Directory Help
Search

Invoke-RestMethod does not handle http response code 204 correctly by Dirk-Jan Smits


Status: 

Active


7
0
Sign in
to vote
Type: Bug
ID: 785369
Opened: 4/23/2013 3:12:45 AM
Access Restriction: Public
1
Workaround(s)
view
1
User(s) can reproduce this bug

Description

LS,

The Invoke-RestMethod keeps waiting for a body, even when the response code is 204 (No Content), after a while a timeout occurs and the statement returns this error:

Invoke-RestMethod : The operation has timed out
At line:83 char:15
Details
Sign in to post a comment.
Posted by Joshua Taliaferro on 5/20/2014 at 9:41 AM
I can confirm that this is an issue on PowerShell 4 using Windows 8.1 x64. The specific REST API I've been working uses the 204 response code to indicate a success that does not require any content to be returned, so this is a game-breaking bug for me. I've had to fall back on Invoke-WebRequest.
Sign in to post a workaround.
Posted by dlrohm on 6/28/2013 at 8:24 PM
I had this issue when calling a REST method on an Artifactory server. Invoke-RestMethod chokes on 204 response and ends up timing out consistently. I changed this to Invoke-WebRequest and it works fine.