title: Outlook Rest Api sending Mail Request returned status 400
body: <p>I try to send email from a signed Outlook Account with Outlook Rest Api and Curl then I get this error</p>
  
  <pre><code>Request returned status 400
  </code></pre>
  
  <p>This is my code for sending mail </p>
  
  <pre><code>private static $outlookApiUrl = "https://outlook.office.com/api/v2.0";
  
    public static function sendMail ($access_token,$user_email,$subject,$Content,$email){
  
      $arr= array(
          "Message" =&gt;array(
         'Subject' =&gt; $subject,
        "Body"=&gt;array(
            "Content-Type"=&gt;"HTML",
            "Content"=&gt;$Content,
          ),
        "ToRecipients"=&gt;array(
          array(
              "EmailAddress"=&gt;array(
                  "Address"=&gt;$email,
                )
            ),
          ),
      ));
  
      $json=json_encode($arr, true);
  
       $getMessagesUrl = self::$outlookApiUrl."/me/sendmail";
  
  
      return self::makeApiCall($access_token, $user_email, "POST",$getMessageUrl,$json);
  
   } 
  </code></pre>
  
  <p>and this is the code for CURL</p>
  
  <pre><code>public static function makeApiCall($access_token, $user_email, $method, $url, $payload = NULL) {
        // Generate the list of headers to always send.
      $headers = array(
          "User-Agent: php-tutorial/1.0",         
          "Authorization: Bearer ".$access_token, 
          "Accept: application/json",             
          "client-request-id: ".self::makeGuid(), 
          "return-client-request-id: true", 
          "X-AnchorMailbox: ".$user_email
          );
  
      $curl = curl_init($url);
  
      switch(strtoupper($method)) {
        case "POST":
        error_log("Doing POST");
        $headers[] = "Content-Type: application/json";
        curl_setopt($curl, CURLOPT_POST, true);
        curl_setopt($curl, CURLOPT_POSTFIELDS, $payload);
        break;
        default:
        error_log("INVALID METHOD: ".$method);
        exit;
      }
  
      curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
      curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
      $response = curl_exec($curl);
      error_log("curl_exec done.");
  
      $curl_errno = curl_errno($curl);
      $curl_err = curl_error($curl);
      if ($curl_errno) {
         //PRINT ERROR
      }
      else {
        error_log("Response: ".$response);
        curl_close($curl);
        return json_decode($response, true);
      }
    }
  </code></pre>
  
  <p>THEN I call the sendMail method at Home page</p>
  
  <pre><code>  $send=OutlookService::sendMail($_SESSION["access_token"], $_SESSION["user_email"],"testing","&lt;html&gt;&lt;body&gt;testing email.&lt;/body&gt;&lt;/html&gt;","example@gmail.com");
  
      echo var_dump($send);
  </code></pre>
  
  <p>Can I know what's wrong with my code ? and why would I get this error?</p>