我正在尝试使用带有HTTP请求的Gmail API发送电子邮件。 参考链接:https://developers.google.com/gmail/api/v1/reference/users/messages/send
我调用API的示例代码:-
/*HTTP Request*/
POST https://www.googleapis.com/gmail/v1/users/{userId}/messages/send
/*Headers:*/
Authorization: Bearer {accesstoken}
Content-Type: message/rfc822
/*Request body*/
{"raw":"RnJvbTogamhvbndpbHNvbi5lY3Npb25AZ21haWwuY29tIApUbzogaW1yYWFuQGVjc2lvbi5jb20gClN1YmplY3Q6IFNheWluZyBIZWxsbyAKRGF0ZTogMDYtQXVnLTIwMTggMTM6NTA6MzEgKzA1IApNZXNzYWdlLUlEOiA8MTIzNEBsb2NhbC5tYWNoaW5lLmV4YW1wbGU-CgpUaGlzIGlzIGEgbWVzc2FnZSBqdXN0IHRvIHNheSBoZWxsby4gU28sICJIZWxsbyIu"}
发起请求后,API返回以下json响应:
{ "error": { "errors": [ { "domain": "global", "reason": "wrongUrlForUpload", "message": "Uploads must be sent to the upload URL. Re-send this request to https://www.googleapis.com/upload/gmail/v1/users/{userId}/messages/send" } ], "code": 400, "message": "Uploads must be sent to the upload URL. Re-send this request to https://www.googleapis.com/upload/gmail/v1/users/{userId}/messages/send" } }
注意-我没有在电子邮件中传递任何附件。
请让我知道我在请求中做错了。