2

Google Calendar APIを使用していて、イベントを挿入するためのリクエストをAPIに送信しようとしていますが、エラーが発生します。

これは私が送信しているリクエストです:

POST https://www.googleapis.com/calendar/v3/calendars/riteshmehandiratta%40gmail.com/events?key={YOUR_API_KEY}

Content-Type:  application/json
Authorization:  Bearer ya29.AHES6ZQwHy_3OYLmXtZpSa5PIwnBO3hqLWolMXpTYiFOEtjlEmbxNrYn
X-JavaScript-User-Agent:  Google APIs Explorer

{

 "end": {
  "date": "2/14/2007"
 },
 "start": {
  "date": "2/14/2007"
 },
 "kind": "calendar#event",
 "summary": "Hello World"
}

そして私が得ている応答は次のとおりです。

400 Bad Request

- Hide headers -

cache-control:  private, max-age=0
content-encoding:  gzip
content-length:  122
content-type:  application/json; charset=UTF-8
date:  Sat, 23 Mar 2013 17:36:22 GMT
expires:  Sat, 23 Mar 2013 17:36:22 GMT
server:  GSE

{
 "error": {
  "errors": [
   {
    "domain": "global",
    "reason": "badRequest",
    "message": "Bad Request"
   }
  ],
  "code": 400,
  "message": "Bad Request"
 }
}

なぜ悪いリクエストエラーが発生するのか理解できません。

4

2 に答える 2

3

日付形式が間違っていると私が言えることから、APIドキュメントは次のように示しています。

 The date, in the format "yyyy-mm-dd", if this is an all-day event. 

このページの下部にある[試してみる]フォームを使用して、最初にリクエストが有効であることを確認することをお勧めします。

https://developers.google.com/google-apps/calendar/v3/reference/events/insert#try-it

幸運を!

于 2013-03-25T12:18:15.443 に答える
0

これは私がしたことです(PHP):

//Passed in a GET variable name of 'date'
//Tells parser the current format
$dt = DateTime::createFromFormat("d/m/Y", $_GET['date']);

//Adding the event start date, modifying the format to suit googles encoding
$start->setDate($df->format("Y-m-d"));

上記のスクリプトスニペットは私のために働いています。

Rohanはフォーマット条件について正しいです。

于 2014-03-17T13:08:09.443 に答える