0

I am trying to create a new subscription for the DriveItem resource on Microsoft Graph, I have a web application that handles the Files API successfully, I have the ability to authenticate and handle the DriveItem resources succesfully.

When I am trying to create a subscription I am running into an error with the following post request

POST /beta/subscriptions HTTP/1.1
Host: graph.microsoft.com
Authorization: Bearer {{Token}} 
Content-Type: application/json

{
"changeType": "created",
"notificationUrl": "{{callback}}",
"resource": "me/drive/root",
"expirationDateTime": "2022-05-01",
"clientState": ""{{state}}"",
"includeResourceData": true
}

I get the following error

{
"error": {
    "code": "InvalidRequest",
    "message": "Invalid 'changeType' attribute: 'created'.",
    "innerError": {
        "date": "2022-01-02T04:58:06",
        "request-id": "REQUEST-ID",
        "client-request-id": "CLIENT-REQUEST-ID"
    }
}

Not sure what the problem might be, the application is registered as "Accounts in any organizational directory (Any Azure AD directory - Multitenant) and personal Microsoft accounts (e.g. Skype, Xbox)"

I have also checked that the notificationUrl provided is valid and working, not sure what the problem might be, any help would be appreciated

Oscar Marin
  • 136
  • 2
  • 8

1 Answers1

0

As for now it is not supported on driveitems level, but only on drive level. Still your subscription is wrong due to the fact the only allowed changeType is updated , then you will be able to get notified of all the changes on driveitems (without actually knowing what has changed), which I think is what you are trying to achieve.

POST /v1.0/subscriptions HTTP/1.1
Host: graph.microsoft.com
Authorization: Bearer {{Token}} 
Content-Type: application/json

{
"changeType": "updated",
"notificationUrl": "{{callback}}",
"resource": "me/drive/root",
"expirationDateTime": "2022-05-01",
"clientState": "{{state}}",
}

Also consider to use version 1.0 of the API since beta can have unexpected behavior and as for "includeResourceData" attribute, you will never have data, as for drives and driveitems (for other entities you can but).

Zodraz
  • 131
  • 1
  • 7