在google calendar api中插入事件期间解析错误

时间:2017-10-05 05:32:35

标签: parse-error google-calendar-api

我下面是一个json对象,并将其作为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"
}

我还将Content-Type设为application/json。但我得到错误

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

当我通过Try this API发送相同的请求时,其工作正常。请帮助!!!

1 个答案:

答案 0 :(得分:1)

如果您要在实际编码中执行此操作,请使用' apostrophes'而不是" double quotes"喜欢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},
    ],
  },
};