httr GET write_disk: authenticate issue to download a file from a site with password

I am trying to download a csv file from a url with password and I am using httr.
I am doing the following:


GET(url=url_file_csv,authenticate(user="Part1\Part2",password="MyPassword", type="basic"), write_disk(filename))

My original username includes only one backslash (one \), but I had to include two backslashes (two \) to avoid the error message. So, as my username I had to use "Part1\Part2" (using two \, instead of one \ between Part1 and Part2).

The problem is that when I am trying to download the file with GET and write_disk, it is giving error 401 (invalid username or password). I am using the correct username and password, but I had to change the username to include two backslashes ( two \).

I have tried to open the url_file_csv in the web browser, and if I am not logged in it says invalid username or password, but if I am logged in then it automatically downloads the csv file to my computer. So, the link, username and password are correct but it is giving invalid username or password.
Am I missing something?
How can I solve this issue to download the csv file?

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

If you have a query related to it or one of the replies, start a new topic and refer back with a link.