API returns 401 for newly created sites.

Backend Scale 1 Reputation point

I am using API to connect to SP sites details. It works perfectly if the site is old. But when I create a new site ,upload some documents ,now if I try to hit the API it returns 401 with
"{"error":{"code":"AF10001","message":"The permission set () sent in the request does not include the expected permission."}}"


App has the permission 252343-image.png

Microsoft Graph

Microsoft Graph
Read directory data

Office 365 Management APIs
Read activity data for your organization

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
11,145 questions
Microsoft Exchange Online Management
Microsoft Exchange Online Management
Microsoft Exchange Online: A Microsoft email and calendaring hosted service.Management: The act or process of organizing, handling, directing or controlling something.
4,323 questions
{count} votes

1 answer

Sort by: Most helpful
  1. HarmeetSingh7172 4,811 Reputation points

    Hello @Backend Scale

    Thanks for reaching out!

    Possible reasons you're getting this error message:

    1. The above error can occur because of an invalid/expired Client Secret being used. This can be fixed by generating a new Client Secret for the Azure AD application.
    2. Incorrect permissions- Refer this for more details.
    3. Not using correct token to call O365 Management API with required permissions.

    Note: Make sure you've requested (and granted consent for) all the appropriate API permisions.

    Hope this helps.

    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have further questions about this answer, please click "Comment".

    0 comments No comments