From f2c2fd375016566eb8472bb2cae3c1125b877e32 Mon Sep 17 00:00:00 2001 From: abraunegg Date: Thu, 16 Mar 2023 10:49:47 +1100 Subject: [PATCH 1/2] Fix webhook subscription creation for SharePoint Libraries * Create a resource item using the driveId rather than specifying /me/drive/root --- src/onedrive.d | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/onedrive.d b/src/onedrive.d index e5682ffb3..2901ddbdb 100644 --- a/src/onedrive.d +++ b/src/onedrive.d @@ -1012,10 +1012,12 @@ final class OneDriveApi auto expirationDateTime = Clock.currTime(UTC()) + subscriptionExpirationInterval; const(char)[] url; url = subscriptionUrl; + // Create a resource item using the account driveId rather than using /me/drive/root + string resourceItem = "/drives/" ~ driveId ~ "/root:/"; const JSONValue request = [ "changeType": "updated", "notificationUrl": notificationUrl, - "resource": "/me/drive/root", + "resource": resourceItem, "expirationDateTime": expirationDateTime.toISOExtString(), "clientState": randomUUID().toString() ]; From 3fa090d19fffb8e0c4dcc8309b6b564fb0feec0a Mon Sep 17 00:00:00 2001 From: abraunegg Date: Fri, 17 Mar 2023 06:27:32 +1100 Subject: [PATCH 2/2] Update onedrive.d * Update PR --- src/onedrive.d | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/onedrive.d b/src/onedrive.d index 2901ddbdb..58849c0c3 100644 --- a/src/onedrive.d +++ b/src/onedrive.d @@ -1012,8 +1012,15 @@ final class OneDriveApi auto expirationDateTime = Clock.currTime(UTC()) + subscriptionExpirationInterval; const(char)[] url; url = subscriptionUrl; - // Create a resource item using the account driveId rather than using /me/drive/root - string resourceItem = "/drives/" ~ driveId ~ "/root:/"; + // Create a resource item based on if we have a driveId + string resourceItem; + if (driveId.length) { + resourceItem = "/drives/" ~ driveId ~ "/root"; + } else { + resourceItem = "/me/drive/root"; + } + + // create JSON request to create webhook subscription const JSONValue request = [ "changeType": "updated", "notificationUrl": notificationUrl,