Share via

Creating subscription with "prefer:includesecuritywebhooks"

yusufugurozbek 5 Reputation points
2024-10-24T14:30:52.5533333+00:00

Hello,

I'd like to get notified when there is a sharing change on drive items (Business SharePoint/OneDrive). To do that, I created a subscription with the prefer:includesecuritywebhooks option as mentioned here. The below code doesn't help me. Could you please guide me on that?


async def create_subscription():

    expiration_date_time: datetime = datetime.now(tz=tz.UTC) + timedelta(minutes=42300)

    request_body = Subscription(

        change_type="updated",

        notification_url="{WEBHOOK_URL}",

        resource="/drives/{DRIVE_ID}}/root",

        expiration_date_time=expiration_date_time,

        client_state="secretClientValue",

    )

    headers_collection = HeadersCollection()

    headers_collection.add("prefer", "includesecuritywebhooks")

    request_configuration = RequestConfiguration(headers=headers_collection)

    return await client.subscriptions.post(

        request_body, request_configuration=request_configuration

    )

Thanks,

Yusuf Ugur

Microsoft Security | Microsoft Graph

Your answer

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