I am trying to download a file from an https link c# code returns a 401 Unauthorized. The download works with the sample java code and also through the browser.

C# Code:-
Uri uri = new Uri("https://www2.swift.com/bicdownload/bicdownloader?action=getfile&productline=bicdir&product=bicdb&content=delta&format=txt");

HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(SMSUri);
CredentialCache cache = new CredentialCache();
cache.Add(uri, "Basic", new NetworkCredential("user", "pass"));
webRequest.Credentials = cache;
string usernamePassword = "user" + ":" + "pass";
string authInfo = Convert.ToBase64String(Encoding.Default.GetBytes(usernamePassword));
webRequest.Headers["Authorization"] = "Basic " + authInfo;
webRequest.ProtocolVersion= HttpVersion.Version11;
webRequest.Method = "GET";
//webRequest.Timeout = TimeOut;
webRequest.PreAuthenticate = true;
HttpWebResponse response = (HttpWebResponse)webRequest.GetResponse();

This gives a 401 unauthorized exception,
This service imposes the basic authentication method, which mandates that client applications set
the HTTPS header with a username and password pair for every request. There is no cookie
returned to the requestor, because there is no application session maintained on the server.

java code:-
public static void main(String[] args) {
int exitcode = 0;
int statusCode;
String url = "https://www2.swift.com/bicdownload/bicdownloader?"
HttpClient client = new HttpClient();
GetMethod method = new GetMethod(url);
// Provide custom retry handler if required
new DefaultHttpMethodRetryHandler(3, false));
try {
// We strongly recommend obfuscation of password and restricted
access to its storage
Properties prop = new Properties();
InputStream fis = (InputStream)new FileInputStream("E:/KK/
// Set Credentials
UsernamePasswordCredentials credentials;
credentials = new UsernamePasswordCredentials(prop.getProperty("username"), prop.getProperty("password"));
client.getState().setCredentials(new AuthScope("www2.swift.com", 443), credentials);
// Executing the method.
statusCode = client.executeMethod(method);
//Get the file size from the response body and do something with it
Header[] contlen = method.getResponseHeaders("Content-Length");
if (contlen.length != 0) {
StringTokenizer stone = new StringTokenizer
(contlen[0].getValue(), "=");
int size = new Integer(stone.nextToken()).intValue();
// Do something with the file size
System.out.println("File size is: " + size);
// Get the filename from the response body.
InputStream is = method.getResponseBodyAsStream();

Please let me know where going wrong, I have written lots of code calling external interface but this one is tricky

Please help