我正在尝试使用Google gmail API发送电子邮件。我已经使用了带有承载令牌和Content-Type的Request body JSON-message / rfc822。
然后我使用下面的链接发送帖子请求,但收到以下错误。如何解决此问题????
发布请求链接-
https://www.googleapis.com/upload/gmail/v1/users/kasunysoft@gmail.com/messages/send
请求正文
{
"threadId": "Hi kasunjith",
"payload": {
"mimeType": "message/rfc822",
"headers": [
{
"name": "To",
"value": "hvn@gmail.com"
},
{
"name": "From",
"value":"kasunysoft@gmail.com"
},
{
"name":"Subject",
"value":"Subject Text"
}
]
}
}
我得到了答复
{
"error": {
"errors": [
{
"domain": "global",
"reason": "invalidArgument",
"message": "Recipient address required"
}
],
"code": 400,
"message": "Recipient address required"
}
}
答案 0 :(得分:0)
这意味着您发送电子邮件的格式无效。检查文档Users.messages和Users.messages: send的格式是否正确。
{ "id": string, "threadId": string, "labelIds": [ string ], "snippet": string, "historyId": unsigned long, "internalDate": long, "payload": { "partId": string, "mimeType": string, "filename": string, "headers": [ { "name": string, "value": string } ], "body": users.messages.attachments Resource, "parts": [ (MessagePart) ] }, "sizeEstimate": integer, "raw": bytes }
您还可以查看以下SO帖子,以更深入地讨论有关您的错误。