使用Postman将图像添加到gmail api发送消息
我正在向gmail API发送发布请求
https://www.googleapis.com/upload/gmail/v1/users/userId/messages/send?upload=multipart
,带有以下标题
Authorization Bearer [Your Token]
Content-Type: multipart/related; boundary="foo_bar_baz"
并要求正文为
--foo_bar_baz
Content-Type: application/json; charset=UTF-8
{
}
--foo_bar_baz
Content-Type: message/rfc822
MIME-Version: 1.0
to: receiver@xxx.com
from: sender@xxx.com
subject: Testing API Automation
--foo_bar_baz
Content-Type: text/plain; charset="UTF-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
This is the testing text
--foo_bar_baz
Content-Type: image/jpeg
MIME-Version: 1.0
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="Steps1.jpg"
--foo_bar_baz--
我不确定是否需要在请求正文中附加图像或将图像转换为rfc822格式。
目前,我得到以下回应
Bad content type. Please use multipart.