如何解决尝试更新事件时出现“参数数量无效”错误
我正在尝试通过Google Apps脚本更新日历事件。我有日历ID,事件ID和要尝试作为变量更新的对象:
var eventinfo = {
"calendarId": calID
"eventId": eventID,"resource": {
"description": "1234"
}
};
//update the event description and location
var updater;
try {
updater = Calendar.Events.update(eventinfo);
Logger.log('Successfully updated event: ' + i);
} catch (e) {
Logger.log('Fetch threw an exception: ' + e);
}
我收到此错误:
Fetch引发了一个异常:异常:提供的参数数量无效。预计只有3-5个
以前,我曾尝试以这种方式.update(calID,eventID,eventinfo)
调用更新方法,其中事件信息只是一个带有描述的对象,但是返回的错误提示是错误的呼叫。
我认为我的对象参数中缺少某些内容。
解决方法
问题:
-
首先,您忘记了
eventinfo
定义中的逗号 在第一行和第二行之间。 -
但是,我认为您的方法无效,因为您没有 在
event object
函数中传递Calendar.Events.update()
。结构应该是这样的:Calendar.Events.update( event,calendarId,event.id );
解决方案/示例:
-
下面的示例在将来更新第一个事件。在 特别是,它会更新标题(摘要),说明和位置,但 随意修改,如果需要的话:
function updateNextEvent() { const calendarId = 'primary'; const now = new Date(); const events = Calendar.Events.list(calendarId,{ timeMin: now.toISOString(),singleEvents: true,orderBy: 'startTime',maxResults: 1 }); var event = events.items[0]; //use your own event object here if you want event.location = 'The Coffee Shop'; event.description = '1234'; event.summary = 'New event'; event = Calendar.Events.update( event,event.id ); }
当然,不要忘记从资源 => 高级Google服务打开Calendar API。
参考文献:
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。