I have tried to make a simple console application that retrieves list items from Share Point Online. It works fine when I retrieve list of the sites or list titles from the site, but I receive no list items when I try to get it from the particular list. Source list contains less then 50 items and this list was made by using "GenericList" template ("CustomList", ListTemplateId=100).
I've listed many examples of similar tasks and almost all of them were written in the same way. That's why I don't exclude that thet reason of my case might be in an insufficient permissions (I attach a screenshot of the API permissions).
Also I checked that item-level permissions is set to "1" - allow user read all items.
Please, check my code and app permissions. Any help will be highly appreciated.
using SP = Microsoft.SharePoint.Client;
static async Task Main(string args)
Uri site = new Uri("https://MyCompany.sharepoint.com/sites/MyProject");
string user = $"ServiceUser@MyCompany.com";
string rawPassword = $"password";
SecureString password = new SecureString();
foreach (char c in rawPassword) password.AppendChar(c);
using (var authenticationManager = new AuthenticationManager()) //HELPER CLASS TO OBTAIN ACCESS TOKEN
using (var context = authenticationManager.GetContext(site, user, password))
//RETRIVING LIST TITLE - WORKS FINE
Web web = context.Web;
lists => lists.Include(list => list.Title,
list => list.Id));
foreach (SP.List list in web.Lists)
//RETRIVING LIST ITEM
Web myWeb = context.Web;
SP.List myList = myWeb.Lists.GetByTitle("List_of_Items");
SP.ListItemCollection listItemCollection = myList.GetItems(CamlQuery.CreateAllItemsQuery());
eachItem => eachItem.Include(
item => item,
item => item["Title"],
item => item["ID"]
foreach (SP.ListItem listItem in listItemCollection)
Console.WriteLine("ID: " + listItem["ID"].ToString() + "Title: " + (string)listItem["Title"].ToString());