rest - How to get HTTP status on Invoke-WebRequest/Invoke-RestMethod when using -OutFile parameter? -


i have request restful api (note, happens both invoke-webrequest , invoke-restmethod):

$resp1 = invoke-webrequest -outfile $clusterconfigzipfile -uri $apifolder -body $filecontent -method 'post' -credential $admincredentials -contenttype "application/x-www-form-urlencoded" -erroraction silentlycontinue -verbose 

i know works ok because:

  • it downloads zip file correct.
  • if use fiddler can see response headers (http 200) capture of fiddler

my problem code returning nothing in $resp1. have read "feature" when use -outfile.

is there anyway capture response or @ least response code powershell?

as documented, use -passthru parameter if want response returned in addition being written file.

-outfile<string>

saves response body in specified output file. enter path , file name. if omit path, default current location.

by default, invoke-webrequest returns results pipeline. send results file , pipeline, use passthru parameter.


Comments

Popular posts from this blog

Fail to load namespace Spring Security http://www.springframework.org/security/tags -

sql - MySQL query optimization using coalesce -

unity3d - Unity local avoidance in user created world -