An error occurred when using the create subscription api 'Resource' is invalid.

beem beem 0 Reputation points
2023-09-21T07:13:36.9866667+00:00

Use this account 'beem1@beem2023.onmicrosoft.com' Create an event subscription for this account 'beem2@beem2023.onmicrosoft.com'

request params : {'changeType':'created,updated,deleted','notificationUrl':'https://8b15-39-109-68-195.ngrok-free.app/outlook/callback/notifier','resource':'/users/d31f87b5-5713-4f4e-b494-8fe72268af86/events','expirationDateTime':'2023-09-22T12:14:47.084910+08:00','clientState':'33abeab9-08d3-483b-892b-0ddcd0ce569f'} 成功,返回结果: Response{protocol=http/1.1, code=400, message=Bad Request, url=https://graph.microsoft.com/v1.0/subscriptions}

response msg:

{protocol=http/1.1, code=400, message=Bad Request, url=https://graph.microsoft.com/v1.0/subscriptions}.subResBody:{'error':{'code':'ExtensionError','message':'Operation: Create; Exception: [Status Code: BadRequest; Reason: The value 'https://outlook.office365.com/api/v2.0/Users('d31f87b5-5713-4f4e-b494-8fe72268af86%40aec8009e-b17b-4432-b094-f298ef7d96c4')/Events' of parameter 'Resource' is invalid.]','innerError':{'date':'2023-09-21T04:14:48','request-id':'8b7be429-4046-4cf7-8400-8ea567a63105','client-request-id':'8b7be429-4046-4cf7-8400-8ea567a63105'}}}

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
11,828 questions
{count} votes

1 answer

Sort by: Most helpful
  1. CarlZhao-MSFT 41,286 Reputation points
    2023-09-21T09:44:04.6933333+00:00

    Hi @beem beem

    Creating subscriptions for Outlook REST API resources using the graph API is not supported. If you are trying to subscribe to events in another user's mailbox, please refer to the following example:

    POST https://graph.microsoft.com/v1.0/subscriptions
    Content-type: application/json
    
    {
       "changeType": "created,updated,deleted",
       "notificationUrl": "https://webhook.azurewebsites.net/api/send/myNotifyClient",
       "resource": "users/{id}/events",
       "expirationDateTime":"2016-11-20T18:23:45.9356913Z",
       "clientState": "secretClientValue",
       "latestSupportedTlsVersion": "v1_2"
    }
    

    By the way, if you are trying to subscribe to events for multiple users, then try requesting the /subscriptions API endpoint separately for different users.

    Hope this helps.

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


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.