I am trying to subscribe to notifications from Outlook Mail API. However I keep getting a 400 error. Ref: msdn.microsoft.com/en-us/office/office365/api/notify-rest-operations
$url = 'outlook.office.com/api/v2.0/me/subscriptions';
$headers = array(
"Authorization: Bearer ".$access_token ,
"Accept: application/json",
"X-AnchorMailbox: ".$user_email
);
$curl = curl_init($url);
$data = '{
"@odata.type":"#Microsoft.OutlookServices.PushSubscription",
"Resource": "outlook.office.com/api/v2.0/me/messages",
"NotificationURL": "mydomain.com/listener.php",
"ChangeType": "Created"
}';
$headers[] = "Content-Type: application/json";
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS,$data);
$response = curl_exec($curl);
I haven't setup my listener yet. Is the 400 error because of the listener? Or is it something else?. Seems like the authentication was successful