401:Unauthorized Error when calling Sharepoint Lists Web Service from .NET

asp.netsharepointweb services

I am trying to create Lists in Sharepoint site from my ASP.NET code using the webservice (http://test.sharepoint.com/_vti_bin/Lists.asmx).The code i use is as follows.I am sure i have enough access to that sharepoint site.

sharepoint.enhanced1.Lists wsLists = new SharePoint_Test.sharepoint.enhanced1.Lists();
        wsLists.PreAuthenticate = true;
        wsLists.Credentials = System.Net.CredentialCache.DefaultCredentials;
        wsLists.AddList("Test_Code", "testing", 103);

This Code gives me the error:-
The request failed with HTTP status 401: Unauthorized.
Can anyone help me with this.

Best Answer

It's Working now.. i was using somewhat wrong asmx URL. the one i was using was http://test.sharepoint.com/Lists/_vti_bin/Lists.asmx but the correct URL Shud be http://test.sharepoint.com/_vti_bin/Lists.asmx (**NO /Lists/). Strange thing is that both URL's open up in browser without any problem,but fail in code.

Thanks...

Related Topic