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:
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-webrequestreturns results pipeline. send results file , pipeline, usepassthruparameter.

Comments
Post a Comment