0
votes

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.

3
It has got something do with authorization only. Cross check your credentials and access rights.Pankaj Upadhyay
Well, i have access to the sharepoint site(full access) and i am able to create Lists manually from sharepoint.Not sure what other access is required.AnoojNair

3 Answers

2
votes

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...

1
votes

try it with the default network credentials

wsLists.Credentials = System.Net.CredentialCache.DefaultCredentials;
0
votes

I have the same error and finaly disable ASP.NET Impersonation for my Sharepoint site in IIS Manager.