POST https://graph.microsoft.com/v1.0/subscriptions resulted in a 400 Bad Request

Shruti Malode 0 Reputation points
2024-07-03T05:32:54.5866667+00:00

Below is my code for subscribing notifications from outlook calendar webhooks. The code is not responding with validation token for the client side as unable to complete the POST subscribe request. Please help.

 $client = new \GuzzleHttp\Client();   
 $response = $client->post('https://graph.microsoft.com/v1.0/subscriptions', [
        'headers' => [
            'Authorization' => 'Bearer ' . $accessToken,
            'Content-Type' => 'application/json',
    ],
        'json' => [
            'changeType' => 'created,updated,deleted',
            'notificationUrl' =>  $notifcationUrl,
            'resource' => '/me/events', 
            'expirationDateTime' => $expirationDateTime, 
            'clientState' => '12345678',
        ],
    ]);
Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
11,328 questions
Outlook Management
Outlook Management
Outlook: A family of Microsoft email and calendar products.Management: The act or process of organizing, handling, directing or controlling something.
5,053 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Yakun Huang-MSFT 2,185 Reputation points Microsoft Vendor
    2024-07-03T09:23:50.1266667+00:00

    Hi @Shruti Malode

    According to the Graph API, the notification endpoint must be able to respond to validation requests, and if validation fails, 400 error requests are returned.

    User's image

    See this link for more details:

    https://learn.microsoft.com/en-us/graph/change-notifications-overview#notification-endpoint-validation

    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.