percolatestudio / meteor-google-api

A simple API encapsulating some common patterns regarding Google's APIs
https://atmospherejs.com/percolate/google-api
MIT License
48 stars 30 forks source link

What should options look like in the context of sending an event to calendar api. #17

Closed vacarsu closed 9 years ago

vacarsu commented 9 years ago

I have a method that looks as follows:

var event = {
      'summary': assignmentForm.title,
      'start': {
        'dateTime': assignmentForm.dueDate,
      },
      'end': {
        'dateTime': assignmentForm.dueDate,
      },
    };
    GoogleApi.post('/calendar/v3/calendars/' + student.profile.google.emails[0].value + '/events',
      {
        resource: {
          event: event
        }
      },
      resource => {
        return console.log(resource);
      }
    );

I have tried many different things, just can't seem to get it working. A lack of examples doesn't help that either.

vacarsu commented 9 years ago

Here is the error I get

{ [Error: failed [400] {  "error": {   "errors": [    {     "domain": "global",     "reason": "required",     "message": "Missing end time."    }   ],   "code": 400,   "message": "Missing end time."  } } ]
I20150629-11:14:20.179(-7)?    { statusCode: 400,
I20150629-11:14:20.179(-7)?      content: '{\n "error": {\n  "errors": [\n   {\n    "domain": "global",\n    "reason": "required",\n    "message": "Missing end time."\n   }\n  ],\n  "code": 400,\n  "message": "Missing end time."\n }\n}\n',
I20150629-11:14:20.179(-7)?      headers: 
I20150629-11:14:20.179(-7)?       { vary: 'X-Origin',
I20150629-11:14:20.180(-7)?         'content-type': 'application/json; charset=UTF-8',
I20150629-11:14:20.180(-7)?         date: 'Mon, 29 Jun 2015 18:14:20 GMT',
I20150629-11:14:20.180(-7)?         expires: 'Mon, 29 Jun 2015 18:14:20 GMT',
I20150629-11:14:20.180(-7)?         'cache-control': 'private, max-age=0',
I20150629-11:14:20.180(-7)?         'x-content-type-options': 'nosniff',
I20150629-11:14:20.180(-7)?         'x-frame-options': 'SAMEORIGIN',
I20150629-11:14:20.181(-7)?         'x-xss-protection': '1; mode=block',
I20150629-11:14:20.181(-7)?         server: 'GSE',
I20150629-11:14:20.181(-7)?         'alternate-protocol': '443:quic,p=1',
I20150629-11:14:20.181(-7)?         'accept-ranges': 'none',
I20150629-11:14:20.181(-7)?         'transfer-encoding': 'chunked' },
I20150629-11:14:20.181(-7)?      data: { error: [Object] } } }
I20150629-11:19:33.901(-7)? Exception from sub student-points-earned id KXWNgkWxaGR7SFrYL Error: Publish function can only return a Cursor or an array of Cursors
I20150629-11:19:33.902(-7)?     at [object Object]._.extend._runHandler (packages/ddp/livedata_server.js:1028:1)
I20150629-11:19:33.902(-7)?     at [object Object]._.extend._startSubscription (packages/ddp/livedata_server.js:769:1)
I20150629-11:19:33.902(-7)?     at [object Object]._.extend.protocol_handlers.sub (packages/ddp/livedata_server.js:582:1)
I20150629-11:19:33.903(-7)?     at packages/ddp/livedata_server.js:546:1
tmeasday commented 9 years ago

Hi @vacarsu it looks like you just need to look at the gcal API for the format it expects the event to be in. This libraries API is essentially the same as http://docs.meteor.com/#/full/http

vacarsu commented 9 years ago

I was missing the { data: {} } part. Got it working now.