Using HTTP Request to download file via URL

I am processing emails and using an Assign activity with the following Regex command to get the URL from inside the email.

System.Text.RegularExpressions.Regex.Match(EmailBodyText,“(?<=<).*(?=>)”).Value

I then want to download the file. The URL doesn’t specify the file name and I only know the name once the file has been returned. How do I specify a folder location to save the file and how do I keep the original file name that is returned via the request?

@craig.norton

Specify the folderpath and file details peoperties panel → options → filename for resource attachment field

After getting the response save the filename and then use rename file to rename it to the required name

This is the method if the uri you are passing is a download link

Or

If it is not the downlaod link and you are getting a response as file then use the option under output → response attachment

Cheers

@Anil_G I have managed to use the HTTP Request activity and have provided the URL from the email and can download to the downloads folder with a predetermined name of File1.pdf. How can I get the original file name from the HTTP Request and then user that the rename and move the file?

I managed to save the Header Output as a dictionary item and then found the Key Value of “Content-Disposition” which contained the File Name. I can then rename the temporary file name with the correct name.

However, the emails also contain URLs to images which are displayed in the email, e.g. PNG files and this value doesn’t exist in the Header Output. Is that what you meant in the statement below?

This is the method if the url you are passing is a download link

Or

If it is not the download link and you are getting a response as file then use the option under output → response attachment

Are there other parameters I should be configuring to deal with this situation?

image

go to the settings pane of your browser and go to downloads
image

Tick the box allowing you to specify the name and location of the file

Use a type into activity to type in the whole pathway and file name

This lets you use any file name of your choosing so it remains the same throughout runs

@Anil_G I ended up getting the File Type from the header and only continue if its a PDF, therefore ignoring any images or text blocks being shown in the email.

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.