Calendars: insert

予備カレンダーを作成します。 今すぐ試すまたは例を見る

リクエスト

HTTP リクエスト

POST https://www.googleapis.com/calendar/v3/calendars

承認

このリクエストには、次のスコープによる認証が必要です。

範囲
https://www.googleapis.com/auth/calendar

詳細については、認証と認可のページをご覧ください。

リクエスト本文

リクエストの本文には、以下のプロパティを使用して Calendars リソースを指定します。

プロパティ名 説明 メモ
必須プロパティ
summary string カレンダーのタイトル。 書き込み可能

レスポンス

成功すると、このメソッドはレスポンスの本文で Calendars リソースを返します。

注: このメソッドで使用可能なコード例では、サポートされているプログラミング言語すべての例を示しているわけではありません(サポートされている言語の一覧については、クライアント ライブラリ ページをご覧ください)。

Java

Java クライアント ライブラリを使用します。

import com.google.api.services.calendar.Calendar;

// ...

// Initialize Calendar service with valid OAuth credentials
Calendar service = new Calendar.Builder(httpTransport, jsonFactory, credentials)
    .setApplicationName("applicationName").build();

// Create a new calendar
com.google.api.services.calendar.model.Calendar calendar = new Calendar();
calendar.setSummary("calendarSummary");
calendar.setTimeZone("America/Los_Angeles");

// Insert the new calendar
Calendar createdCalendar = service.calendars().insert(calendar).execute();

System.out.println(createdCalendar.getId());

Python

Python クライアント ライブラリを使用します。

calendar = {
    'summary': 'calendarSummary',
    'timeZone': 'America/Los_Angeles'
}

created_calendar = service.calendars().insert(body=calendar).execute()

print created_calendar['id']

PHP

PHP クライアント ライブラリを使用します。

$calendar = new Google_Service_Calendar_Calendar();
$calendar->setSummary('calendarSummary');
$calendar->setTimeZone('America/Los_Angeles');

$createdCalendar = $service->calendars->insert($calendar);

echo $createdCalendar->getId();

Ruby

Ruby クライアント ライブラリを使用します。

calendar = Google::Apis::CalendarV3::Calendar.new(
  summary: 'calendarSummary',
  time_zone: 'America/Los_Angeles'
)
result = client.insert_calendar(calendar)
print result.id

試してみよう:

以下の API Explorer を使用して、ライブデータに対してこのメソッドを呼び出し、レスポンスを確認してください。