1

I am running a very simple Console Application to test SharePoint 2010 client object model. Here is the code

using System;
using Microsoft.SharePoint.Client;

class Program
{
    static void Main()
    {
        ClientContext clientContext =
            new ClientContext("http://myserver.contoso.com");
        List list = clientContext.Web.Lists
            .GetByTitle("Announcements");
        clientContext.Load(list);
        clientContext.ExecuteQuery();
        Console.WriteLine("List Title: {0}", list.Title);
        CamlQuery camlQuery = new CamlQuery();
        camlQuery.ViewXml = "<View/>";
        ListItemCollection listItems = list.GetItems(camlQuery);
        clientContext.Load(listItems);
        clientContext.ExecuteQuery();
        foreach (ListItem listItem in listItems)
            Console.WriteLine("Id: {0} Title: {1}",
                oListItem.Id, listItem["Title"]);
    }
}

The problem is everything works fine. It just that the rows are not retrieved from any list or library. The collection is always empty even if there is data in actual list.

Any ideas ?

This example is exact copy paste from MSDN

3
  • Does the "List Title: {0}" print anything?
    – Russell
    Jan 2, 2012 at 22:23
  • No, it does not go into loop. I found it, it was due to insufficient permissions. Jan 3, 2012 at 5:07
  • Really strange!! I can't find any mistake in code...it should work. Hope you ran Visual Studio with Run As Admin attribute..?
    – NICK
    Jan 3, 2012 at 8:58

3 Answers 3

2

Strangely, this was caused by insufficient permissions.

1
  • 1
    Can you shed some light on the permissions you needed? Having the same issue with only some users getting zero results, elevated users getting all results.
    – Michael K
    Oct 5, 2018 at 15:50
0

It's in AppManifest.xml. Under the Permission tab, you can set Scope for List, Search, Site Collection, etc. Once you select the scope you provide a Permission (e.g. FullControl).

Related question here

0

similar issue appeared for me in SP online. Adding proxy to the config file cleared the issue.

Note: added for SP online Developers as the problem statement is same.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.