Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/388.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 谷歌日历。插入返回400';必需的';_Javascript_Google Calendar Api - Fatal编程技术网

Javascript 谷歌日历。插入返回400';必需的';

Javascript 谷歌日历。插入返回400';必需的';,javascript,google-calendar-api,Javascript,Google Calendar Api,我正试图通过GoogleJavaScriptAPI创建一个日历。OAuth身份验证工作正常:我可以通过以下方式获得日历列表: gapi.client.calendar.calendarList.list(); 但是,当我尝试使用以下内容创建日历时: gapi.client.calendar.calendars.insert( { "summary": "A New Calendar", "description": "Generated by Ben", "timezo

我正试图通过GoogleJavaScriptAPI创建一个日历。OAuth身份验证工作正常:我可以通过以下方式获得日历列表:

gapi.client.calendar.calendarList.list();
但是,当我尝试使用以下内容创建日历时:

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"
}
在中,它显示了此响应,但包含缺少的必需参数的列表


有没有办法确定我缺少什么“必需”参数?我已经用进行了测试,我的参数似乎工作正常。

最终解决了这个问题。属性必须位于“资源”对象中:

gapi.client.calendar.calendars.insert(
{
    "resource" :
    {"summary": "A New Calendar",
    "description": "Generated by Ben",
    "timezone" : "Australia/Sydney"}
});
doco没有提到这一点,但是如果您查看对
gapi.auth.authorize
的初始调用的响应,您会发现JSON描述了指定范围内的整个API