Start subscription to get activity for sharepoint sites in microsoft graph.

Anonymous
2024-12-16T21:18:58.8533333+00:00

I have a TS project working on getting users, groups, etc on M365. I want to get usage about SharePoint sites and I'm trying to start a subscription like this but I got an error: "Resource not found for the segment 'activity'. Code: BadRequest, status code 400. Can you please tell me what is wrong with this request?

await client.api('/activity/feed/subscriptions/start?contentType=Audit.SharePoint').post({});

Microsoft 365 and Office | SharePoint | For business | Windows
Microsoft Security | Microsoft Graph
0 comments No comments
{count} votes

Accepted answer
  1. Saranya Madhu-MSFT 2,375 Reputation points Microsoft External Staff
    2024-12-17T01:01:14.8566667+00:00

    Hi @Anonymous ,

    Thanks for reaching out to Microsoft!

    400 error occurs when the request can't be processed because it's malformed or incorrect.

    Please verify that the resource you are trying to subscribe supports change notifications.

    Microsoft Graph API to create a subscription. You can do this via an HTTP POST request to the /subscriptions endpoint.

    {

      "changeType": "updated",

      "notificationUrl": https://your-notification-url.com,

      "resource": "/sites/{site-id}/lists/{list-id}",

      "expirationDateTime": "2024-12-18T11:00:00.000Z",

      "clientState": "secretClientValue"

    }

    Hope this helps.

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


1 additional answer

Sort by: Most helpful
  1. Anonymous
    2024-12-18T12:20:27.8433333+00:00

    I solved the issue. I couldn't use the msgraph to get that kind of data, instead I need to use axios and did the query without any sdk

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.