Download File From URL

Hi ,

I am using the activity, Download File From URL where I am replacing the Save file as with variable file_Name
image

In the Savefile as Do I need to give the custom file name or entire file path. I am getting error in both either giving full name or custom name

Here my file_Name=

It seems like all the subfolders in the download path do not exist beforehand. You can use the Create Folder activity to create necessary subfolders before using the Download File from URL activity.

1 Like

@efelantti

I want to know for this activity, In save file as, do I need to give entire path or just the custome name. I am always getting an error could not find part of the file C:\Users\marina.dutta\Documents\UiPath\PDF-InvoicesDownload but if I keep it blank it downloads default name file. I want to save the file with particular name as

image
when ever I am passing the variable with file-Name in that field I am getting error.

image

If you provide a full path, it will be downloaded according to it. But if the folder that you provide does not exist, the activity will not create it. So, make sure to create first all the folders in the download path.

If the folders exist, perhaps there is an issue with the file_Name variable. Is the Invoice_date a string or a datetime variable? If it’s a datetime, you need to output it to a string (as per default it’s written out with dashes which aren’t allowed in file names → the system interprets as folder separator).

So you could try like this:

file_Name = supplier+"_"+invoice_number+"_"+Invoice_date.ToString("ddMMyyyy")+".pdf"

If that doesn’t help, add a Log message where you print the value of file_Name, or inspect it while debugging.

@marina.dutta

  1. If you give the file name as input then the file will get downloaded to the Project folder with a specific file name.

  2. If you give the full path then the file will be downloaded to the respective path. but all the folders in the path should be accessible to the BOT.

Hey @marina.dutta
It might be because of the date format. Would you please check by changing the date format for “Invoice_date” .
Say Invoice_date = 05/12/2023

For e.g., :
StringVariable = DateTime.ParseExact(Invoice_date,“dd/MM/yyyy”,Nothing).ToString(“ddMMMyyyy”)

Cheers!

@efelantti

image

image

@Jennifer_Serrao

Mostly issue with Date format.

image

Getting error as

Then I guess it’s a string variable. To fix the format you could do the following:

Invoice_date = DateTime.ParseExact(Invoice_date, "MM/dd/yy", Nothing).ToString("ddMMyyyy")
file_Name = supplier+"_"+invoice_number+"_"+Invoice_date+".pdf"

You can replace “ddMMyyyy” with the format of your choice, check eg. this site for some ideas if it’s a new concept: DateTime Format In C# - https://www.c-sharpcorner.com/

Please try replacing the " \ " using String.Replace, maybe with a “_”
For eg.,:
UpdatedInvoiceDate = Invoice_date.Replace("\","_")

Now pass “UpdatedInvoiceDate” variable in place of “Invoice_date”

@Jennifer_Serrao

Getting same error.


image

If you use the Replace function, you don’t need to parse to datetime. And probably you should change it to forward slash “/”.

updated_InvoiceDate = Invoice_date.Replace("/", "")
file_Name = supplier+"_"+invoice_number+"_"+updated_InvoiceDate+".pdf"

Since you are replacing. . You need not parse again.

You can directly use the “updated_InvoiceDate”

Say:
Invoice_date = 06\12\2023

updated_InvoiceDate = Invoice_date.Replace(" \ “,”_")

Therefore Output of updated_InvoiceDate:
06_12_2023

file_Name= supplier+"_"+invoice_number+"_"+updated_InvoiceDate+".pdf"

@Jennifer_Serrao

Thank You. I tried in the below way and it worked.