400错误.收件人地址为必填项.的JavaScript [英] 400 error. Recipient address required. JavaScript

查看:55
本文介绍了400错误.收件人地址为必填项.的JavaScript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Gmail API中逐步进行了简单的请求.

I make a simple request step-by-step in Gmail API.

根据我发出的所有指示:

According to all instructions I made this call:

var request = gapi.client.gmail.users.messages.send({
    'userId': 'me',
    "payload": {
    "headers": [
             {
              "name": "To",
              "value": "########@gmail.com"
             }
           ]},
     'raw': 'SEVMTE8gTVkgREVBUiBGUklFTkQ='
     });

request.then(()=>{console.log('yep')})

但收到错误:

{
   "error": {
   "errors": [
     {
       "domain": "global",
       "reason": "invalidArgument",
       "message": "Recipient address required"
     }
   ],
   "code": 400,
   "message": "Recipient address required"
  }
}

推荐答案

有关如何使用此方法的更生动的示例,请检查此

For a more vivid sample on how to use this method, check this SO post:

[...]完整的消息需要在raw参数中传递,请参见示例:

[...] the complete message needs to be passed in the raw parameter, see the example:

From: John Doe <jdoe@machine.example> 
To: Mary Smith <mary@example.net> 
Subject: Saying Hello 
Date: Fri, 21 Nov 1997 09:55:06 -0600 
Message-ID: <1234@local.machine.example>

This is a message just to say hello. So, "Hello". 

因此,在对base64编码完整的消息之后,在不使用任何其他参数的情况下将其传递到raw参数中,便可以正常工作.

So after base64 encoding the complete message, passing it in the raw parameter without using any other parameter, it works fine.

这篇关于400错误.收件人地址为必填项.的JavaScript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆