RuSs
RuSs

Reputation: 1812

SharePoint Site and Graph API (Beta) - can't find any pages under site and can't create page (access denied)

I am currently working with the SharePoint Graph API (beta) through Postman. I have it all working and my Azure Active Directory application has the correct scopes for SharePoint.

What I am wondering is this:

I have this site (subsite, sorry my SharePoint terminology might not be the best):

https://graph.microsoft.com/{{api-version}}/sites/COMPANY_NAME.sharepoint.com,070d3261-xxxx-4c69-b186-a83e7ee0b6bb,09bc2cd0-aada-45fb-xxxx-bcdce9d5711e:/kb:/

which returns the site I am looking for (Note: I truncated the json):

{
   "@odata.context": "https://graph.microsoft.com/beta/$metadata#sites/$entity",
   "createdDateTime": "2020-05-18T06:02:28Z",
   "description": "",
   "id": "COMPANY_NAME.sharepoint.com,070d3261-xxxx-4c69-b186-a83e7ee0b6bb,e7808145-aab1-xxxx-bccc-df798f6a36eb",
   "lastModifiedDateTime": "2020-09-23T21:37:37Z",
   "name": "kb",
   "displayName": "Knowledge Base - I removed the rest of the json"
}

But when I add /pages to the end:

https://graph.microsoft.com/{{api-version}}/sites/COMPANY_NAME.sharepoint.com,070d3261-xxxx-4c69-b186-a83e7ee0b6bb,09bc2cd0-aada-45fb-xxxx-bcdce9d5711e:/kb:/pages/

I get this:

{
    "@odata.context": "https://graph.microsoft.com/beta/$metadata#Collection(microsoft.graph.sitePage)",
    "value": []
}

Now, I just went and created a new page in that site, even though there were already pages there, so I know they exist.

Another thing to note is that when I try to create a new page via the API:

POST https://graph.microsoft.com/{{api-version}}/sites/{{site-id}}/pages

I get this:

{
    "error": {
        "code": "accessDenied",
        "message": "Access denied",
        "innerError": {
            "date": "2020-09-27T22:56:06",
            "request-id": "1306506d-caea-4748-99a9-7eee20bb6404",
            "client-request-id": "1306506d-caea-4748-99a9-7eee20bb6404"
        }
    }
}

Can anyone help me understand why the collection / array in my response does not contain any pages and also, why I cannot create a new page when my AAD App have the required scopes and these scopes have my admins' consent

cheers

Update. Adding some screen shots: enter image description here enter image description here

Upvotes: 1

Views: 964

Answers (1)

Shiva Keshav Varma
Shiva Keshav Varma

Reputation: 3595

As you said you are using a daemon Application you need to specify right permissions here. The screen shot shows that you are actually adding it for Sharepoint App permissions, please add the Sites.ReadWrite.All for the Microsoft Graph Permissions. As you can see above the green pointer there are 3 permissions(Directory.Read.All, User.Read.All and User.Read), add "Sites.ReadWrite.All" there to get the site pages and also it helps you in creating the pages.

Upvotes: 2

Related Questions