Google日历错误400

时间:2014-02-03 22:24:09

标签: php google-calendar-api google-api-php-client

我正在尝试使用PHP添加/插入Google日历活动,我通过composer install使用google API库。

我已将错误追踪到正在插入的对象(我有令牌)。我做了一个json_encode事件插入到google's online checker进行测试(为此我使用'primary'manageId)

   {
    "creator": null,
    "organizer": null,
    "summary": "Meeting with Bart Simpson",
    "id": null,
    "attendees": null,
    "htmlLink": null,
    "recurrence": null,
    "start": {
        "date": null,
        "timeZone":"Australia/Hobart",
        "dateTime": "2014-02-03T15:00:00+11:00"
    },
    "etag": null,
    "location": "-42.859634, 147.30928399999993",
    "recurringEventId": null,
    "gadget": null,
    "status": null,
    "updated": null,
    "description": "Visit",
    "iCalUID": null,
    "extendedProperties": null,
    "endTimeUnspecified": null,
    "sequence": null,
    "visibility": null,
    "guestsCanModify": null,
    "end": {
        "date": null,
        "timeZone":"Australia/Hobart",
        "dateTime": "2014-02-03T16:00:00+11:00"
    },
    "attendeesOmitted": null,
    "kind": null,
    "locked": null,
    "created": null,
    "colorId": "0",
    "anyoneCanAddSelf": null,
    "reminders": null,
    "guestsCanSeeOtherGuests": null,
    "originalStartTime": null,
    "guestsCanInviteOthers": null,
    "transparency": null,
    "privateCopy": null
}

我从中得到答复:

    400 Bad Request

- Show headers -

{
 "error": {
  "errors": [
   {
    "domain": "global",
    "reason": "invalid",
    "message": "Invalid value for: null is not a valid value"
   }
  ],
  "code": 400,
  "message": "Invalid value for: null is not a valid value"
 }
}

消息中似乎缺少属性名称。 “ ??? 的无效值:”

我尝试过逐步删除项目,但只有在开始和结束时才会显示有效。因为所有的空条目都是由API创建的,所以我认为它们是正确的。

以前工作过,我改变了一些东西,但我不知道是什么。我在睡眠不足的状态下遗失了什么?

1 个答案:

答案 0 :(得分:0)

我也偶然发现了这个问题,并且在与Postman花了一段时间之后,我发现Google API不接受具有空值的字段(出于某些原因)。所以我删除了所有空字段,只留下了具有指定值的字段,它起作用了!希望这对某人有帮助:)

P.S。您可以使用Google日历文档上的“尝试一下”模式来试用并验证您的请求