我正在使用“内置”AdvancedApps 脚本日历 API(不是 REST API)并尝试创建新的日历事件,但我收到错误:
无效的来源网址:
我直接从日历中获取日历 ID,所以我认为不是这样的。
function createCalEvent() {
var event, calendarId, endTime, newEvent, options,
response, resource, startTime, title, url;
var cal = CalendarApp.getCalendarsByName("Main Calendar");
calendarId = cal[0].getId();//
Logger.log('calendarId: ' + calendarId)
title = "Test Event Title";
startTime = "2018-7-18T09:00:00";
endTime = "2018-7-18T12:00:00";
resource = {
"start": {
"dateTime": startTime,
"timeZone": "GMT-08:00"
},
"description": "Test the description",
"source": {
"title": title
}
}
if (endTime) {
var o = {
"dateTime": endTime,
"timeZone": "GMT-08:00"
}
resource.end = o;
} else {
resource.endTimeUnspecified = true;
}
response = Calendar.Events.insert(resource, calendarId);
Logger.log('response: \n' + response)
}
我正在尝试设置活动的标题。
当它为 Calendar.Events.insert() 设置事件标题时,请包含该属性summary
在请求正文中。source
不是为了给活动标题。所以请修改如下。
修改后的脚本:
resource = {
"start": {
"dateTime": startTime,
"timeZone": "GMT-08:00"
},
"description": "Test the description",
"summary": "event title", // Added
// "source": {"title": title} // Removed
}
Note :
- 如果您在请求正文中使用“来源”,请同时包含两者
source.title
and source.url
like "source": {"title": title, "url": "http://localhost"}
. When source.url
不包括在内,错误为Invalid source url: .
occurs.
参考 :
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)