REST Service.Download file.

Ask your Windows PowerShell-related questions, including questions on cmdlet development!
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Locked
User avatar
nikolay
Posts: 9
Joined: Wed May 18, 2016 2:23 am

REST Service.Download file.

Post by nikolay » Mon Mar 04, 2019 2:26 am

Hello! I have a problems with REST service. May be somebody can help me.
My purpose - is download file from REST Service.

This is a path where my file is sitiated and i need to download it. I use this command.

Code: Select all

$uri = 'https://portal.com/rapi2/Messages/111c15af-24d1-47e3-8ce2-21dc5ea3ea0b/download'
$response = Invoke-RestMethod -Uri $uri -Headers $headers -Method get |  Out-File -FilePath "C:\1\123.pdf"
I understand that to do so properly, and in PDF in fact returns the result of the command.
But i want only to download file. How can i do this used Rest-Method? Thank you!

User avatar
jvierra
Posts: 13803
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: REST Service.Download file.

Post by jvierra » Mon Mar 04, 2019 5:31 am

Hi,

Unfortunately there is not enough information to even offer a guess. Also you cannot output from both ends of the pipeline.

Code: Select all

$uri = 'https://portal.com/rapi2/Messages/111c15af-24d1-47e3-8ce2-21dc5ea3ea0b/download'
Invoke-RestMethod -Uri $uri -Headers $headers -Method get | 
    Out-File -FilePath C:\1\123.pdf
You need to contact the service to find out the requirements for using REST to download files.

User avatar
nikolay
Posts: 9
Joined: Wed May 18, 2016 2:23 am

Re: REST Service.Download file.

Post by nikolay » Wed Mar 06, 2019 7:15 am

Thank you! I read information about REST and solve problem!

User avatar
jvierra
Posts: 13803
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: REST Service.Download file.

Post by jvierra » Wed Mar 06, 2019 7:46 am

I always review documentation first. An error, deficiency or anomaly always helps me to see some new thing in the docs that I had missed.

Locked