2015-11-03 46 views
3

我正在嘗試使用Google Calendar API在Google日曆中插入事件。Google Cal API - 插入事件時「缺少結束時間」

事件資源,我將:

{ 
    "summary": "test", 
    "location": "test", 
    "description": "test", 
    "start": { 
    "dateTime": "2015-11-02T10:00:00-05:00", 
    "timeZone": "America/Toronto" 
    }, 
    "end": { 
    "dateTime": "2015-11-02T11:00:00-05:00", 
    "timeZone": "America/Toronto" 
    }, 
    "attachments": [ 
    { 
     "fileUrl": "" 
    } 
    ], 
    "attendees": [ 
    { 
     "email": "[email protected]" 
    }, 
    { 
     "email": "[email protected]" 
    } 
    ], 
    "reminders": { 
    "useDefault": false, 
    "overrides": [ 
     { 
     "method": "email", 
     "minutes": 1440 
     }, 
     { 
     "method": "popup", 
     "minutes": 10 
     } 
    ] 
    } 
} 

此事件被作爲一個POST請求https://www.googleapis.com/calendar/v3/calendars/calendarId/events的身體。我沒有使用任何圖書館。

我一直得到「缺少結束時間」的錯誤。我發現了一些類似的問題,如this one,他(她)是一個使用JavaScript庫,並建議發送以下爲正文:

{ 
    resource:<event above>, 
    calendarId:<calendarId> 
} 

但這並沒有在我的情況下工作,也許是因爲我不不要使用圖書館。我不認爲它很重要,但我在Meteor應用程序中這樣做。任何想法?

編輯 原來這畢竟是流星相關的問題。我在使用他們的HTTP lib時犯了一個錯誤。

回答

1

此事件被髮送作爲POST請求的主體到 https://www.googleapis.com/calendar/v3/calendars/calendarId /事件。如果這是一個O型或沒有,但我用我試試,你的日期發送的請求

不知道,它的作品我貼到我的主日曆

POST https://www.googleapis.com/calendar/v3/calendars/primary/events?key={YOUR_API_KEY} 

它不是calendarId字符串其您要插入的日曆的ID。您還必須在最後添加訪問令牌。

我送什麼

POST https://www.googleapis.com/calendar/v3/calendars/primary/events?key={YOUR_API_KEY} 
{ 
"end": { 
    "dateTime": "2015-11-02T11:00:00-05:00", 
    "timeZone": "America/Toronto" 
}, 
"start": { 
    "dateTime": "2015-11-02T10:00:00-05:00", 
    "timeZone": "America/Toronto" 
}, 
"description": "test", 
"summary": "test" 
} 
+0

原來這是最後一個流星相關的問題。我用他們的http庫犯了一個錯誤。對不起,並感謝你 – znat

+0

Np我試過,因爲我有一個日期問題一次。這可能會很棘手。 – DaImTo

相關問題