2013-07-02 3 views
6

V3 REST API를 통한 일괄 요청을 사용하여 Google 캘린더 일정을 가져 오거나 추가/업데이트하는 방법은 무엇입니까? 노력했지만 작동하지 않습니다. 문서 (https://developers.google.com/google-apps/calendar/batch)에 따르면 다중 파트/혼합 콘텐츠 형식의 메시지를 API에 게시하여 일괄 요청을 보낼 수 있어야합니다. 작동하는 HTTP POST의 예가 좋습니다.Google 캘린더 V3 REST API의 일괄 요청

감사합니다, Riyaz

답변

1

다음 배치 요청은 eventId2을 업데이트는 eventId1을 얻고 calendarId로 식별되는 달력에 새 이벤트를 만듭니다.

POST /batch HTTP/1.1 
Authorization: /*Auth token*/ 
Host: host 
Content-Type: multipart/mixed; boundary=batch_foobarbaz 
Content-Length: total_content_length 

--batch_foobarbaz 
Content-Type: application/http 
Content-ID: <item1:[email protected]> 

GET /calendar/v3/calendars/calendarId/events/eventId1 

--batch_foobarbaz 
Content-Type: application/http 
Content-ID: <item2:[email protected]> 

PUT /calendar/v3/calendars/calendarId/events/eventId2 
Content-Type: application/json 
Content-Length: part_content_length 

{{ body }} 

--batch_foobarbaz 
Content-Type: application/http 
Content-ID: <item3:[email protected]> 

POST /calendar/v3/calendars/calendarId/events 
Content-Type: application/json 
Content-Length: part_content_length 

{{ body }} 

--batch_foobarbaz-- 
+0

/일괄 요청에 사용되는 전체 URL은 무엇입니까? "http://www.googleapis.com/batch"를 사용해 보았지만 실패했습니다 ... 알려주세요. – Jagadeesh

+0

엔드 포인트는 다음과 같습니다. http://www.googleapis.com/batch – ade

0

엔드 포인트는 내가 배치 요청을 일정 할 때 나를 위해 작동

https://www.googleapis.com/batch

입니다. 내가 가지고 있었던 한 가지 문제는 마지막 경계 토큰과 함께 내가 그 후에 --을 가지지 않았기 때문입니다. 따라서 각 토큰은 --으로 시작하고 마지막 토큰은 --입니다. @ Burcu Dogan의 예에서 볼 수 있듯이.