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

javascript - How to process users in one specific order using map o each function? -

java - Two interface have same method name with different return type -

javascript - Linking from page A to a specific iframe on page B -