API returns 401 for newly created sites.

Backend Scale 1 Reputation point
2022-10-20T06:38:52.063+00:00

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."}}"

TargetURL=https://manage.office.com/api/v1.0/f60ddc44-81aa-4051-8cb3-4642acf87c23/activity/feed/subscriptions/content?contentType=DLP.All&startTime=2022-10-20T04:54:35Z&endTime=2022-10-20T05:24:35Z

App has the permission 252343-image.png

Microsoft Graph
Sites.ReadWrite.All

Microsoft Graph
Directory.Read.All
Read directory data

Office 365 Management APIs
ActivityFeed.Read
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,464 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,386 questions
{count} votes

1 answer

Sort by: Most helpful
  1. HarmeetSingh7172 4,811 Reputation points
    2022-10-21T12:06:26.403+00:00

    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