【发布时间】:2015-01-15 20:48:42
【问题描述】:
我正在尝试使用 Gmail REST API 将邮件标记为已读。
$('#markGmailRead').click(function(){
var request = $.ajax({
type: 'POST',
dataType: 'json',
headers: { "Authorization": "Bearer <<ACCESS KEY>>",
"Content-Type": "application/json"},
url: 'https://www.googleapis.com/gmail/v1/users/me/messages/<<MESSAGEID>>/modify',
data: {"addLabelIds": ["UNREAD"]}
})
request.done(function(data){
// when the Deferred is resolved.
console.log(data);
})
request.fail(function(){
// when the Deferred is rejected.
console.log('fail');
})
})
这会返回以下 json:
{
"error": {
"errors": [
{
"domain": "global",
"reason": "parseError",
"message": "Parse Error"
}
],
"code": 400,
"message": "Parse Error"
}
}
有其他人经历过吗?我不知道是什么原因造成的。
【问题讨论】:
-
为什么标题上写着
Mark message as read,而数据里有"addLabelIds": ["UNDREAD"]?
标签: javascript jquery rest gmail-api