0

I've a json object below and passed it as urlParameter

{
  "end": {
    "dateTime": "2017-10-09T13:30:00",
    "timeZone": "America/Denver"
  },
    "start": {
  "dateTime": "2017-10-09T12:00:00",
    "timeZone": "America/Denver"
  },
  "description": "Added through API",
  "summary": "Lecture on Global Warming",
  "location": "Denver"
}

I've also set the Content-Type as application/json. But I get the error as

{ 
    "error": 
    { 
       "errors": [ { 
            "domain": "global", 
            "reason": "parseError", 
            "message": "Parse Error" } ], 
       "code": 400, 
       "message": "Parse Error" 
    }
}

When I send the same request through Try this API its working fine. Please Help!!!

Varshini
  • 187
  • 1
  • 6
  • 20

1 Answers1

1

If you're going to do that in actual coding, use 'apostrophes' and not "double quotes" like what's indicated in the Events.insert sample :

var event = {
  'summary': 'Google I/O 2015',
  'location': '800 Howard St., San Francisco, CA 94103',
  'description': 'A chance to hear more about Google\'s developer products.',
  'start': {
    'dateTime': '2015-05-28T09:00:00-07:00',
    'timeZone': 'America/Los_Angeles',
  },
  'end': {
    'dateTime': '2015-05-28T17:00:00-07:00',
    'timeZone': 'America/Los_Angeles',
  },
  'recurrence': [
    'RRULE:FREQ=DAILY;COUNT=2'
  ],
  'attendees': [
    {'email': 'lpage@example.com'},
    {'email': 'sbrin@example.com'},
  ],
  'reminders': {
    'useDefault': false,
    'overrides': [
      {'method': 'email', 'minutes': 24 * 60},
      {'method': 'popup', 'minutes': 10},
    ],
  },
};
ReyAnthonyRenacia
  • 17,219
  • 5
  • 37
  • 56
  • when i try to validate the json with apostrophes in online json validator, it shows error stating double-quotes should be given – Varshini Oct 05 '17 at 13:56
  • are you even really coding this? i coded this using the quickstart and the event.insert sample in NodeJS and got it working. it seems to me your just in the 'hypothesis/theory' phase and you've done no real coding yet. – ReyAnthonyRenacia Oct 05 '17 at 14:09
  • Sorry actually I'm implementing it in an application as a small part, so that's why making sure before i touch that code – Varshini Oct 06 '17 at 10:37
  • don't "test" in production code. create a sample small project you can tweak and conduct your experiments there. – ReyAnthonyRenacia Oct 06 '17 at 10:38