Skip to main content
Question

Rest Get method - download pdf file

  • January 10, 2025
  • 5 replies
  • 91 views

Forum|alt.badge.img+1

Hello,

I am using rest web services package - 3.21.3

Requirement - To download pdf file

Issue -  I am able to hit the end url and get response as byte stream, but if i check download file and give the path to be downloaded its not working(path is with file name)

Error : Api response is empty because file does not exist

 

Is it issue with the package? or am i missing anything

5 replies

Aaron.Gleason
Automation Anywhere Team
Forum|alt.badge.img+10
  • Automation Anywhere Team
  • 567 replies
  • January 10, 2025

Have you tried using Browser: Download file if this is a simple GET request?

Another suggestion is using Python and either the Requests or cURL functions. Let me know if you need an example.


Forum|alt.badge.img+1
  • Author
  • Cadet | Tier 2
  • 2 replies
  • January 10, 2025

Please do share an example if possible


Aaron.Gleason
Automation Anywhere Team
Forum|alt.badge.img+10
  • Automation Anywhere Team
  • 567 replies
  • January 10, 2025

How about this?
 

This simple automation prompts for a filename, then uses a GET request to download the file to the temp folder. This is only a sample as it has no error handling.

If you’re performing simple GETs, I would still recommend the Browser: Download file action instead of using Python.


Forum|alt.badge.img+1
  • Author
  • Cadet | Tier 2
  • 2 replies
  • January 10, 2025

Sorry i might not have given all the details here. I need to do this download file option itself if possible

If i check download file option i am getting below error. If the option is not checked i am getting response value
(file path : C:\Robotics\Downloads\2bd82f58-d8d1-454e-9d46-9937ca5e3e40.pdf)

I tried different approach of sending response and writing it to pdf, but i need to pass api key here
API key is in credential and i am only able to do this if its sent in string format - I could not pursue this option

 


Aaron.Gleason
Automation Anywhere Team
Forum|alt.badge.img+10
  • Automation Anywhere Team
  • 567 replies
  • January 10, 2025

Your line that sets the “headers” variable is going to return a dictionary variable. If I use print(type(headers)) it reports “<class ‘dict’>”.

However, if I change that line to this:

headers = "{'X-Myndshft-Api-Key':'" + listElement[0] + "'}"

...it reports as “<class ‘str’>”, which is what you need. You’re building a string this way, not a dictionary.


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings