Coffeescript Hubot Google日历忙/闲表示未设置timemin
我正在尝试编写一个hubot脚本来轮询Google日历,以获取每个日历的忙/闲信息。问题是请求返回错误消息:Coffeescript Hubot Google日历忙/闲表示未设置timemin,coffeescript,google-api,google-calendar-api,Coffeescript,Google Api,Google Calendar Api,我正在尝试编写一个hubot脚本来轮询Google日历,以获取每个日历的忙/闲信息。问题是请求返回错误消息:缺少timeMin参数,即使在正文中设置了timeMin module.exports = (robot) -> robot.respond /ar|what (room|rooms) (is|are) available\?|available (rooms|room)\?/i, (msg) -> apiKey = 'MyAPIkey' url = "https://www.
缺少timeMin参数
,即使在正文中设置了timeMin
module.exports = (robot) ->
robot.respond /ar|what (room|rooms) (is|are) available\?|available (rooms|room)\?/i, (msg) ->
apiKey = 'MyAPIkey'
url = "https://www.googleapis.com/calendar/v3/freeBusy?key=#{ apiKey }"
d = new Date()
now = d.toISOString()
endOfDay = "#{ now.substr(0, 11) }23:59:59#{ now.substr(19) }"
roomCalendars = []
for alias, room of rooms
roomCalendars.push room.id
post_data = JSON.stringify({
'timeMin': now
'timeMax': endOfDay
items: roomCalendars
})
robot.http(url)
.post(post_data) (err, res, body) ->
if err or res.statusCode isnt 200
msg.send 'I\'ve encountered an error trying to get an available room. Sorry!'
return
msg.send 'Here'
这将返回:
{
"error": {
"errors": [
{
"domain": "global",
"reason": "required",
"message": "Missing timeMin parameter."
}
],
"code": 400,
"message": "Missing timeMin parameter."
}
}
post_数据为:
{"timeMin":"2014-08-07T18:11:27.761Z","timeMax":"2014-08-07T23:59:59.761Z","items":[{"id":"id1"},{"id":"id2"},{"id":"id3"},{"id":"id4"},{"id":"id5"}]}
使用某些网络分析仪或任何其他“调试实用程序”,您是否检查了
timeMin
是否真的作为POST请求的参数发送?@SylvainLeroux我真的不知道如何查看它是否真的被发送,但当我打印POST\u数据时,它肯定是设置好的。你确定它的时间格式正确吗?@thedeadlybutter是的-直接从谷歌Api复制的Explorer@General_Twyckenham ? 这将允许您检查是否真正作为请求发送。这无疑有助于缩小问题的范围。