title: 400 Error. Recipient address required. curl
body: <p>I used Gmail API with curl.(
  <a href="https://developers.google.com/gmail/api/v1/reference/users/messages/send" rel="nofollow noreferrer">Users.messages: send</a>)</p>
  
  <p>But I recieve Error 400 recipient address required.</p>
  
  <p><strong>Command</strong></p>
  
  <pre><code>curl -X POST -H "Authorization: Bearer *****" -H "Content-Type:message/rfc822" -d "{'raw':'Encoded Value'}" "https://www.googleapis.com/upload/gmail/v1/users/me/messages/send"
  </code></pre>
  
  <p><strong>Response</strong></p>
  
  <pre><code>{
     "error": {
       "errors": [
          {
           "domain": "global",
           "reason": "invalidArgument",
           "message": "Recipient address required"
         }
       ],
       "code": 400,
       "message": "Recipient address required"
     }
   }
  </code></pre>
  
  <p><br>
  The encoded value was created by the following python script.</p>
  
  <pre><code>import base64
  from email.mime.text import MIMEText
  from email.utils import formatdate
  
  MAIL_FROM = "example@gmail.com"
  MAIL_TO = "example@gmail.com"
  
  def create_message():
      message = MIMEText("Gmail body: Hello world!")
      message["from"] = MAIL_FROM
      message["to"] = MAIL_TO
      message["subject"] = "gmail api test"
      message["Date"] = formatdate(localtime=True)
  
      byte_msg = message.as_string().encode(encoding="UTF-8")
      byte_msg_b64encoded = base64.urlsafe_b64encode(byte_msg)
      str_msg_b64encoded = byte_msg_b64encoded.decode(encoding="UTF-8")
  
      return {"raw": str_msg_b64encoded}
  
  print(create_message())
  </code></pre>