title: Notification endpoint validation not working with Laravel Endpoint
body: <p>I am using the Microsoft Graph and I need to set up a webhook to receive changes to email and calendar events. I was able to get it working with my PHP Laravel application, but now that I am trying to subscribe to notifications, I am running into issues with validating the <code>notificationUrl</code>, which is pointing to a public server of mine. </p>
  
  <p>The script for creating the webhook is returning the following error:</p>
  
  <pre><code>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...)
  </code></pre>
  
  <p>The truncated part I believe is </p>
  
  <blockquote>
    <p>Subscription validation request failed. Must respond with 200 OK to this request.</p>
  </blockquote>
  
  <p>Here is my code for creating the subscription:</p>
  
  <pre><code>$data = [
      "changeType" =&gt; "created",
      "notificationUrl" =&gt; "https://anatbanielmethod.successengine.net/office365/webhooks/events",
      "resource" =&gt; "me/events",
      "expirationDateTime" =&gt; "2018-12-20T18:23:45.9356913Z",
      "clientState" =&gt; "secret",
  ];
  
  $result = $graph-&gt;createRequest('POST', '/subscriptions')
      -&gt;attachBody($data)
      -&gt;execute();
  </code></pre>
  
  <p>and here is my method for my <code>notificationUrl</code>:</p>
  
  <pre><code>public function events()
  {
      //if validationToken exists return that to validate notificationUrl
      if(isset($_REQUEST['validationToken'])){
          return response($_REQUEST['validationToken'], 200)
              -&gt;header('Content-Type', 'text/plain');
      }
  
      //process event normally for those that have already been validated
  }
  </code></pre>
  
  <p>Once again this URL is <a href="https://anatbanielmethod.successengine.net/office365/webhooks/events" rel="nofollow noreferrer">public and live</a> and I have tested it by using Postman to send it test posts and it is working fine. Also, I added this route to my <code>VerifyCsrfToken</code> middleware to allow a third party post to hit this URL.</p>
  
  <p>Originally I set up a simple single page PHP script to test validating the <code>notificationUrl</code> and that simple script worked fine. It successfully validates Webhooks created that point to it. Here is that one page script code:</p>
  
  <pre><code>&lt;?php
      if(isset($_REQUEST['validationToken'])){
          echo $_REQUEST['validationToken']; // needed only once when subscribing
      } else {
        //process like normal not a validation Token request...
          }
      }
  </code></pre>
  
  <p>So I would expect that the Laravel endpoint would work like the simple one page PHP script, and it is when I test both URLs in Postman, but the Laravel endpoint is not validating when Office365 attempts to validate it when creating a new webhook. </p>
  
  <p>I have searched all over for help on this and read through all of the Microsoft developer documentation I can find on webhooks and these are some of the more helpful parts of the documentation but I am still not finding an answer to this issue:</p>
  
  <ul>
  <li><p><a href="https://docs.microsoft.com/en-us/graph/api/subscription-post-subscriptions?view=graph-rest-1.0" rel="nofollow noreferrer">https://docs.microsoft.com/en-us/graph/api/subscription-post-subscriptions?view=graph-rest-1.0</a></p></li>
  <li><p><a href="https://docs.microsoft.com/en-us/graph/webhooks#notification-endpoint-validation" rel="nofollow noreferrer">https://docs.microsoft.com/en-us/graph/webhooks#notification-endpoint-validation</a></p></li>
  </ul>
  
  <p>Any ideas of this?</p>