lundi 13 février 2017

Google Calendar Events API for Insert throwing 400

Vote count: 0

I have checked out other posts related to this issue and they are not the same: I am using "response", I copied the date/time from the google api website so the format is correct, and I've played around with the headers. Any other ideas for why this is not working?

I'm getting the following error:

Error: failed [400] {  "error": {   "errors": [    {     "domain": "global",     "reason": "required",     "message": "Missing end time."    }   ],   "code": 400,   "message": "Missing end time."  } } [object Object]

My code below broken down into steps: the url i'm going to POST, the user access token, the options for the inserted calendar event including headers and the event with start, end and event summary, and the actual http post and callback function:

calendarSchedule() {
    if(Meteor.user() && moment(Meteor.user().services.google.expiresAt) > moment()._d) {
      var url = "http://ift.tt/1nyM66n";
      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);
        });
    }
  }

asked 1 min ago

Let's block ads! (Why?)



Google Calendar Events API for Insert throwing 400

Aucun commentaire:

Enregistrer un commentaire