I am trying to download a file protected by htaccess password:
This is my code from my test.sh
file
#!/bin/sh
powershell -Command "(New-Object Net.WebClient).DownloadFile('http://myuser:mypassword@servername.nl/path/to/file/call.csv', 'file.csv')"
powershell -Command "Invoke-WebRequest http://myuser:mypassword@servername.nl/path/to/file/call.csv -OutFile file.csv"
If I access it from the browser it works. But from the console by running the command: sh test.sh I got this error:
This server could not verify that you are authorized to access the document requested. Either you supplied the wrong credentials (e.g., bad password), or your browser doesn't understand how to supply the credentials required.
Any idea how can I fix this?