2013-03-23 127 views
1

我正在使用Google Calendar API,並且正在嘗試向API發送插入事件的請求,但出現錯誤。400錯誤的請求在Google日曆中插入事件

這是我發送請求:

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" 
} 
} 

我無法弄清楚,爲什麼我得到一個錯誤的請求錯誤。

回答

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")); 

腳本片段上方爲我工作。

羅漢對他們的格式化條件是正確的。