Google Calendar.Insert API返回400'必填' [英] Google Calendar.Insert API returning 400 'required'
问题描述
我正在尝试通过Google JavaScript API创建日历。 OAuth身份验证工作正常:我可以使用以下命令获取日历列表:
I'm trying to create a calendar via the Google javascript API. OAuth authentication is working fine : I'm able to get a list of calendars using:
gapi.client.calendar.calendarList.list();
但是,当我尝试使用以下内容创建日历时:
However, when I try to create a calendar with:
gapi.client.calendar.calendars.insert(
{
"summary": "A New Calendar",
"description": "Generated by Ben",
"timezone" : "Australia/Sydney"
});
我得到:
{
"error": {
"code": 400,
"message": "Required",
"data": [
{
"domain": "global",
"reason": "required",
"message": "Required"
}
]
},
"id": "gapiRpc"
}
在< a href =http://code.google.com/apis/urlshortener/v1/getting_started.html#errors =nofollow> doco用于其他API 它显示了此响应,但是列出了缺少所需的参数。
In doco for other APIs it shows this response, but with a list of the required arguments that are missing.
有没有办法确定我缺少的'必需'参数?我使用 API Explorer <进行了测试/ a>并且我的参数似乎工作正常。
Is there any way to determine what 'required' parameter I'm missing? I've tested it with the API Explorer and my parameters appear to work fine.
推荐答案
最后想出来了。属性需要位于资源对象中:
Finally figured this out. The properties need to be in a 'resource' object:
gapi.client.calendar.calendars.insert(
{
"resource" :
{"summary": "A New Calendar",
"description": "Generated by Ben",
"timezone" : "Australia/Sydney"}
});
doco没有提到这个,但是如果你看一下对初始调用的响应 gapi.auth.authorize
你会发现JSON描述了你指定范围的整个API。
The doco doesn't mention this, but if you look at the response to the initial call to gapi.auth.authorize
you'll find JSON describing the entire API for the scope you've specified.
这篇关于Google Calendar.Insert API返回400'必填'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!