0
この問題に関連する他の投稿をチェックしていますが、同じではありません。「応答」を使用しています。Google apiのウェブサイトから日時をコピーしました。正しい、私はヘッダーと一緒に遊んだ。なぜこれが機能しないのか他のアイデア?GoogleカレンダーイベントAPI for Insert throw 400
私は次のエラーを取得しています:
Error: failed [400] { "error": { "errors": [ { "domain": "global", "reason": "required", "message": "Missing end time." } ], "code": 400, "message": "Missing end time." } } [object Object]
以下のステップに分けマイコード:私はPOSTに行くよ、URL、ユーザーのアクセストークン、ヘッダを含む挿入されたカレンダーイベントのためのオプションそして、開始、終了とイベントの概要、および実際のHTTP POSTやコールバック機能付きのイベントは:
calendarSchedule() {
if(Meteor.user() && moment(Meteor.user().services.google.expiresAt) > moment()._d) {
var url = "https://www.googleapis.com/calendar/v3/calendars/primary/events";
var userAccessToken = Meteor.user().services.google.accessToken;
var options = {
headers : {
'Content-Type': 'application/json',
'Authorization': 'Bearer ' + userAccessToken,
'X-JavaScript-User-Agent': "Google APIs Explorer",
},
calendarId: 'primary',
resource : {
start: { dateTime: "2016-05-03T18:03:58+02:00" },
end: { dateTime: "2016-05-03T18:03:58+02:00" },
summary: "testSummar",
}
};
HTTP.post(url, options,
function(error,result) {
console.log("posted to calendar? "+ error+ result);
});
}
}