Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Monday, August 7, 2017 2:35 AM
I use following command to download a file.
Invoke-RestMethod -Method Post -Body $obj -ContentType 'application/x-www-form-urlencoded' -Uri $downloadurl -Verbose -OutFile "$downloaddir$i.tar"
The above command's out is below:
OUTPUT: File is returned as the response object.
I need to get login key and token key for further Invoke-Restmethod communication with the system e.g. in order to download any additional file etc.
I am told the logon key and token key have to be extracted from the response headers as the file is returned instead of a JSON object.
I need help how to extract above information, what command to be used?
All replies (4)
Monday, August 7, 2017 2:46 AM
No command. Just reference the "ResponseHeaders" in the returned object.
\(ツ)_/
Tuesday, August 8, 2017 2:36 AM
No command. Just reference the "ResponseHeaders" in the returned object.
\(ツ)_/
Will you kindly provide an example? The previous command downloads the file in octet stream under OutFile location.
Thanks.
Tuesday, August 8, 2017 2:43 AM
$response = Invoke-RestMethod ....
$response.ResponseHeaders
Don't use "OutFile"
Assuming that there are headers. Without the ability to call you method this issue cannot be easily demonstrated.
\(ツ)_/
Sunday, August 13, 2017 4:16 AM
I still need help for responseHeaders
I tried below, but it doesn't do the desired work:
$response=Invoke-RestMethod -Method Post -Body $obj -ContentType 'application/x-www-form-urlencoded' -Uri $downloadurl -Verbose
Write-Output $response.responseHeaders
I don't see anything displayed on the screen after octet stream is returned for $response. Nothing is returned for $response.responseHeaders
payload
VERBOSE: received 56401920-byte response of content type
application/octet-stream
Also how can I save the response file in a directory?