在 google 日历 api 中插入事件期间解析错误
Parse Error during insert event in 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 发送相同的请求时,它工作正常。请帮忙!!!
如果您打算在实际编码中这样做,请使用“apostrophes
”,而不是像 Events.insert sample 中指示的那样使用“double quotes
”:
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},
],
},
};
我在下面有一个 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 发送相同的请求时,它工作正常。请帮忙!!!
如果您打算在实际编码中这样做,请使用“apostrophes
”,而不是像 Events.insert sample 中指示的那样使用“double quotes
”:
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},
],
},
};