I've been unsuccessfully trying to make my application consume SharePoint data.
I followed these steps from c-sharpcorner.com
AllSites.Read doesnt have the status granted, but since it says "Admin consent required: No", I didnt bother, not sure if that's causing the issue.
So, the issue: I've been trying to retrieve a specific list from the SharePoint. With the same user I used to register the required application on Azure AD, I can access this list directly through the web browser, I can even see a XML file with all lists of this subsite if I access
When I try to access a specific list by name or id I receive an 'Access is denied' exception.
What did I do wrong? am I missing another permission here?
CodePudding user response:
To access specific list you need AllSites.Manage
delegated API permission.
Try to also load site
and web
before loading list
if it works.
var mySite = context.Site;
context.Load(mySite);
var web = context.Web;
context.Load(web);
var lists = context.Web.Lists;
context.Load(lists);
context.ExecuteQuery();
CodePudding user response:
Base on my research and testing, if you want to retrieve a specific list, you can use the following code (Note: You need to have AllSites.Read
permissions):
List targetList = clientContext.Web.Lists.GetByTitle("List Name");
In addition, if you want to update or delete a specific list, AllSites.FullControl
permission is required.
More information for reference: SharePoint CSOM API