Link to home
Start Free TrialLog in
Avatar of Demosthenes
Demosthenes

asked on

c# SharePoint 2010

The code below works when I point it to two of my three SharePoint servers.  My third server I get 401 error.  Any ideas anyone ?

    private void button3_Click(object sender, EventArgs e)
      {
        label3.Text = "";
        try
        {
          treeview1.Nodes.Clear();
          ClientContext clientContext = new ClientContext(comboBox1.Text);
          Web oWebsite = clientContext.Web;
          ListCollection collList = oWebsite.Lists;
          clientContext.Load(collList);
          clientContext.ExecuteQuery();
          foreach (SP.List oList in collList)
          {
            TreeNode listnode = new TreeNode();
            listnode.Text = oList.Title;
            treeview1.Nodes.Add(listnode);
          }
        }
        catch (Exception ex)
        { label3.Text = ex.Message; }
      }  

Open in new window

Avatar of Jamie McAllister
Jamie McAllister
Flag of Switzerland image

Are you using Kerberos?
Avatar of Demosthenes
Demosthenes

ASKER

Yes
ASKER CERTIFIED SOLUTION
Avatar of Jamie McAllister
Jamie McAllister
Flag of Switzerland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Through reading these articles I installed Fiddler, and watched my transaction.  Something about the hostname looked odd to me so I used IP address instead.  Code now works.  The hostname of course works when you put it in a browser, but not in my code.  

"http://sp1" is a browsable sharepoint server, but this line doesn't like it:
ClientContext clientContext = new ClientContext(comboBox1.Text);

I am having my server team put in a nice DNS entry for the server.