title: Office 365 REST API to create and sendmail using CURL gets HTTPCode 400 Bad Request
body: <pre><code>curl -X POST -d "{\"@odata.type\":\"#Microsoft.OutlookServices.Message\",\"Subject\":\"Have you seen this new Mail REST API\",\"Importance,\"Body\":{\"ContentType\":\"Text\",\"Content\":\"It looks awesome\"},\"ToRecipients\":[\"Name\":\"Hope Gross\",\"Address\":\"hope@contoso.com\"}]}" https://outlook.office365.com/api/v1.0/me/sendmail --header "Content-Type:application/json" --insecure --verbose --user "user@domain.com:password"
  </code></pre>
  
  <p>I receive following error:</p>
  
  <pre><code>* Hostname was NOT found in DNS cache
  *   Trying 132.245.160.44...
  * Connected to outlook.office365.com (132.245.160.44) port 443 (#0)
  * successfully set certificate verify locations:
  *   CAfile: none
    CApath: /etc/ssl/certs
  * SSLv3, TLS handshake, Client hello (1):
  * SSLv3, TLS handshake, Server hello (2):
  * SSLv3, TLS handshake, CERT (11):
  * SSLv3, TLS handshake, Server key exchange (12):
  * SSLv3, TLS handshake, Server finished (14):
  * SSLv3, TLS handshake, Client key exchange (16):
  * SSLv3, TLS change cipher, Client hello (1):
  * SSLv3, TLS handshake, Finished (20):
  * SSLv3, TLS change cipher, Client hello (1):
  * SSLv3, TLS handshake, Finished (20):
  * SSL connection using ECDHE-RSA-AES256-SHA384
  * Server certificate:
  *    subject: C=US; ST=Washington; L=Redmond; O=Microsoft Corporation; OU=Exchange; CN=outlook.com
  *    start date: 2014-07-24 18:34:15 GMT
  *    expire date: 2016-07-23 18:34:15 GMT
  *    issuer: C=US; ST=Washington; L=Redmond; O=Microsoft Corporation; OU=Microsoft IT; CN=Microsoft IT SSL SHA1
  *    SSL certificate verify ok.
  * Server auth using Basic with user 'user@domain.com'
  &gt; POST /api/v1.0/me/sendmail HTTP/1.1
  &gt; Authorization: Basic ZmFpemFsLmJoQGZvY3VzaXRlLmNvbTpBRkJIQDc2NzU=
  &gt; User-Agent: curl/7.35.0
  &gt; Host: outlook.office365.com
  &gt; Accept: */*
  &gt; Content-Type:application/json
  &gt; Content-Length: 247
  &gt; 
  * upload completely sent off: 247 out of 247 bytes
  &lt; HTTP/1.1 400 Bad Request
  &lt; Cache-Control: private
  &lt; Content-Type: text/html
  * Server Microsoft-IIS/8.0 is not blacklisted
  &lt; Server: Microsoft-IIS/8.0
  &lt; request-id: d12eac31-32c2-458f-a70c-ff44e57c44ef
  &lt; Set-Cookie: ClientId=UHHCPWIEOIUVFTQNTG; expires=Wed, 28-Oct-2015 07:02:23 GMT; path=/; HttpOnly
  &lt; X-CalculatedBETarget: sixpr02mb0638.apcprd02.prod.outlook.com
  &lt; X-MS-Credentials-Expire: 13
  &lt; OData-Version: 4.0
  &lt; X-DiagInfo: SIXPR02MB0638
  &lt; X-BEServer: SIXPR02MB0638
  &lt; X-AspNet-Version: 4.0.30319
  &lt; Set-Cookie: exchangecookie=983848404bbc4c26bb86bda3b3281937; expires=Wed, 28-Oct-2015 07:02:28 GMT; path=/; HttpOnly
  &lt; Set-Cookie: X-BackEndCookie2=user@domain.com=u56Lnp2ejJqByJ2bzprLzs/Sz5nNmtLLzJzH0sfHnc/SxpvLx5vLzMrHyZvMgZmQnIqMloua0ZyQkoHNz87L0s7O0s3Iq8/Ixc/NxczNgZ6PnI+Nm8/N0Y+NkJvRkIqLk5CQlNGckJI=; expires=Thu, 27-Nov-2014 07:02:32 GMT; path=/api; secure; HttpOnly
  &lt; Set-Cookie: X-BackEndCookie=user@domain.com=u56Lnp2ejJqByJ2bzprLzs/Sz5nNmtLLzJzH0sfHnc/SxpvLx5vLzMrHyZvMgZmQnIqMloua0ZyQkoHNz87L0s7O0s3Iq8/Ixc/NxczN; expires=Thu, 27-Nov-2014 07:02:32 GMT; path=/api; secure; HttpOnly
  &lt; X-Powered-By: ASP.NET
  &lt; X-FEServer: SIXPR06CA013
  &lt; Date: Tue, 28 Oct 2014 07:02:32 GMT
  &lt; Content-Length: 11
  &lt; 
  * Connection #0 to host outlook.office365.com left intact
  Bad Request
  </code></pre>
  
  <p>I have searched the internet and in stackoverflow but similar questions have no answer I'm looking for.</p>
  
  <p>How could I create &amp; send mail using CURL?, I have tested it on Linux too but have the same results.</p>