rest - Powershell Invoke-RestMethod POST Method timeout issue -


i'm trying write program deletes files specific device. device has rest api , can access cli without problems.

for example if write in cli, works :

$clip="test.mov" $clipsurl="http://123.45.67.89/clips" $cliptodelete=@{action="delete";clipname=$clip} invoke-restmethod -uri $clipsurl -body $cliptodelete -method post -contenttype "application/x-www-form-urlencoded" 

i can play around $cliptodelete parameter (changing value of $clip) , works every time.

now when put in loop (in main script) works first time, , times out next.

foreach($clip in $listclips) { $clip="test.mov" $clipsurl="http://123.45.67.89/clips" $cliptodelete=@{action="delete";clipname=$clip} invoke-restmethod -uri $clipsurl -body $cliptodelete -method post -contenttype "application/x-www-form-urlencoded" } 

while debuging can see values passed parameters invoke-restmethod correct (the url & body correct).

my first impression should close session (if makes sense) before trying post again.

i tried adding sessionvariable parameter command didnt change thing

does know how close web sesion left open (with new invoke-restmethod command) ? or think issue lies elsewhere ?

thank you.

i had faced similar issues while invoking rest apis airwatch. evidently bug has been filed post & delete methods below:

https://connect.microsoft.com/powershell/feedback/details/836732/tcp-connection-hanging-in-close-wait-when-using-invoke-restmethod-with-put-or-delete

but did face issue intermittently requests too, documented workarounds had use in below technet wiki article, maybe can try , improve if find :

http://social.technet.microsoft.com/wiki/contents/articles/29863.powershell-rest-api-invoke-restmethod-gotcha.aspx


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -