I am trying to subscribe to calendar events but get a 400 with no reason. Any help would be great. Thanks.
Here is the response:
"Client error: POST https://graph.microsoft.com/v1.0/subscriptions
resulted in a 400 Bad Request
response: { "error": { "code": "InvalidRequest", "message": "Subscription validation request failed. Response must ex (truncated...) "
Here is my subscription post in PHP
$subscription = [
"changeType" => "created",
"notificationUrl" => $notificationUrl,
// "resource" => "me/calendars/$calendarId/events", // want to do this but not clear if this will work
"resource" => "me/events",
"expirationDateTime" => date('c',strtotime('+4 hour +20 minutes')),
"latestSupportedTlsVersion" => "v1_2"
];
$graph = new Graph();
$graph
->setBaseUrl("https://graph.microsoft.com")
->setApiVersion("v1.0")
->setAccessToken($token['access_token']);
try {
$result = $graph->createRequest("POST", "/subscriptions")
->addHeaders(array("Content-Type" => "application/json"))
->attachBody($subscription)
->setTimeout("1000")
->execute();
return json_decode(json_encode($result));
} catch(Exception $ex){
error_log(__METHOD__." Error: ".$ex->getMessage());
}