指定カレンダーへの予定の作成で’INVALID_CALENDAR_PROPERTY’が返る

ratan_8128

2023.07.18既読 377

GASで指定カレンダーへの予定作成を試みています。
下のコードはユーザーID(userId),カレンダーID(calendarId),ログインID(email),予定ID(eventId),予定の内容(title),アクセストークン(accessToken)を渡し、指定のカレンダーに予定作成させる関数です。
アクセストークンについてはscopeにcalendarを指定しています。
指定カレンダーの予定を取得する関数についても同じように作りましたが、そちらでは正しく取得できています。
どなたか下の関数を実行して結果を教えてもらえませんか?
また、間違いに気づいた方がいましたら指摘お願いします。
function createLWCalendarEvent(userId,calendarId,email,eventId,title,accessToken){

const encodedUserId = encodeURIComponent(userId)

const url = `https://www.worksapis.com/v1.0/users/${encodedUserId}/calendars/${calendarId}/events`
const options = {
method: 'post',
headers: {
'Authorization': `Bearer ${accessToken}`,
'Content-Type': 'application/json'
},
"muteHttpExceptions" : true,
payload: JSON.stringify({
"eventComponents": [
{
"eventId": eventId,
"summary": title,
"organizer": {
"email": email
},
"start": {
"dateTime": "2023-07-18T18:00:00",
"timeZone": "Asia/Tokyo"
},
"end": {
"dateTime": "2023-07-18T20:00:00",
"timeZone": "Asia/Tokyo"
},
"reminders": [
{
"method": "DISPLAY",
"trigger": "-PT10M"
}
]
}
]
})
}

const response = JSON.parse(UrlFetchApp.fetch(url, options).getContentText());
console.log("↓POST_response")
console.log(response)

}

コメント1

  • 업데이트 된 답글입니다.

    ratan_8128 投稿者

    自己解決しました。
    emailで渡していたのがカレンダーの固有メールアドレスではなく、自身のメールアドレスのためエラーになっていました。

    2023.07.18

    1
前の投稿 Webhookのようなカレンダーイベントの作成、編集、削除といったアクションを検出してくれるAPIはありますか?
次の投稿Is there any api that can detect calendar event's create,edit or delete action like webhook?
リスト

まだ、解決できませんか?
今すぐ実際に使用しているLINE WORKSユーザーに質問してみましょう。