メソッド
メソッド | 戻り値の型 | 概要 |
---|---|---|
get | Object | HTTP レスポンスのヘッダーの属性と値のマップを返します。複数の値を持つヘッダーは配列として返されます。 |
get | Blob | このオブジェクト内のデータを、指定されたコンテンツ タイプに変換された blob として返します。 |
get | Blob | このオブジェクト内のデータを blob として返します。 |
get | Byte[] | HTTP レスポンスの未加工のバイナリ コンテンツを取得します。 |
get | String | 文字列としてエンコードされた HTTP レスポンスのコンテンツを取得します。 |
get | String | 指定された charset の文字列としてエンコードされた HTTP レスポンスのコンテンツを返します。 |
get | Object | HTTP レスポンスのヘッダーの属性と値のマップを返します。 |
get | Integer | HTTP レスポンスの HTTP ステータス コード(OK の場合は 200 など)を取得します。 |
詳細なドキュメント
get All Headers()
HTTP レスポンスのヘッダーの属性と値のマップを返します。複数の値を持つヘッダーは配列として返されます。
// The code below logs the HTTP headers from the response // received when fetching the Google home page. const response = UrlFetchApp.fetch('http://www.google.com/'); Logger.log(response.getAllHeaders());
戻る
Object
- HTTP ヘッダーの JavaScript キー/値マップ
get As(contentType)
このオブジェクト内のデータを、指定されたコンテンツ タイプに変換された blob として返します。このメソッドは、ファイル名に適切な拡張子(「myfile.pdf」など)を追加します。ただし、最後のピリオドの後に続くファイル名の一部(存在する場合)は、置き換える必要がある既存の拡張子であると想定されます。その結果、「ShoppingList.12.25.2014」は「ShoppingList.12.25.pdf」になります。
コンバージョンの 1 日あたりの割り当てを確認するには、Google サービスの割り当てをご覧ください。新しく作成された Google Workspace ドメインには、一時的に厳しい割り当てが適用されることがあります。
パラメータ
名前 | 型 | 説明 |
---|---|---|
content | String | 変換先の MIME タイプ。ほとんどの BLOB では、'application/pdf' が唯一の有効なオプションです。BMP、GIF、JPEG、PNG 形式の画像の場合、'image/bmp' 、'image/gif' 、'image/jpeg' 、'image/png' のいずれも有効です。Google ドキュメントの場合、'text/markdown' も有効です。 |
戻る
Blob
- BLOB としてのデータ。
get Blob()
get Content()
HTTP レスポンスの未加工のバイナリ コンテンツを取得します。
// The code below logs the value of the first byte of the Google home page. const response = UrlFetchApp.fetch('http://www.google.com/'); Logger.log(response.getContent()[0]);
戻る
Byte[]
- コンテンツ(未加工のバイナリ配列)
get Content Text()
文字列としてエンコードされた HTTP レスポンスのコンテンツを取得します。
// The code below logs the HTML code of the Google home page. const response = UrlFetchApp.fetch('http://www.google.com/'); Logger.log(response.getContentText());
戻る
String
- HTTP レスポンスのコンテンツ(文字列)
get Content Text(charset)
指定された charset の文字列としてエンコードされた HTTP レスポンスのコンテンツを返します。
// The code below logs the HTML code of the Google home page with the UTF-8 // charset. const response = UrlFetchApp.fetch('http://www.google.com/'); Logger.log(response.getContentText('UTF-8'));
パラメータ
名前 | 型 | 説明 |
---|---|---|
charset | String | HTTP レスポンス コンテンツのエンコードに使用する文字セットを表す文字列 |
戻る
String
- 指定された文字セットを使用してエンコードされた HTTP レスポンスのコンテンツ
get Headers()
HTTP レスポンスのヘッダーの属性と値のマップを返します。
// The code below logs the HTTP headers from the response // received when fetching the Google home page. const response = UrlFetchApp.fetch('http://www.google.com/'); Logger.log(response.getHeaders());
戻る
Object
- HTTP ヘッダーの JavaScript キー/値マップ
get Response Code()
HTTP レスポンスの HTTP ステータス コード(OK の場合は 200 など)を取得します。
// The code below logs the HTTP status code from the response received // when fetching the Google home page. // It should be 200 if the request succeeded. const response = UrlFetchApp.fetch('http://www.google.com/'); Logger.log(response.getResponseCode());
戻る
Integer
- HTTP レスポンス コード(OK の場合は 200 など)。