Получите код статуса HTTP (200 для ОК и т. д.) ответа HTTP.
Подробная документация
get All Headers()
Возвращает карту атрибутов/значений заголовков для HTTP-ответа, при этом заголовки, имеющие несколько значений, возвращаются в виде массивов.
// The code below logs the HTTP headers from the response// received when fetching the Google home page.constresponse=UrlFetchApp.fetch('http://www.google.com/');Logger.log(response.getAllHeaders());
Возвращаться
Object — карта ключей и значений JavaScript HTTP-заголовков
get As(contentType)
Возвращает данные из этого объекта в виде двоичного двоичного объекта, преобразованного в указанный тип контента. Этот метод добавляет соответствующее расширение к имени файла, например, "myfile.pdf". Однако предполагается, что часть имени файла после последней точки (если таковая имеется) — это существующее расширение, которое следует заменить. Следовательно, "ShoppingList.12.25.2014" преобразуется в "ShoppingList.12.25.pdf".
Чтобы узнать о ежедневных квотах на конверсии, см. раздел Квоты для сервисов Google . На вновь создаваемые домены Google Workspace могут временно распространяться более строгие квоты.
Параметры
Имя
Тип
Описание
content Type
String
MIME-тип для преобразования. Для большинства объектов BLOB-объектов единственно допустимым вариантом является 'application/pdf' . Для изображений в форматах BMP, GIF, JPEG или PNG также допустимы варианты 'image/bmp' , 'image/gif' , 'image/jpeg' или 'image/png' . Для документа Google Docs также допустим вариант 'text/markdown' .
Получает необработанное двоичное содержимое HTTP-ответа.
// The code below logs the value of the first byte of the Google home page.constresponse=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.constresponse=UrlFetchApp.fetch('http://www.google.com/');Logger.log(response.getContentText());
Возвращаться
String — содержимое HTTP-ответа в виде строки.
get Content Text(charset)
Возвращает содержимое HTTP-ответа, закодированное как строка заданной кодировки.
// The code below logs the HTML code of the Google home page with the UTF-8// charset.constresponse=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.constresponse=UrlFetchApp.fetch('http://www.google.com/');Logger.log(response.getHeaders());
Возвращаться
Object — карта ключей и значений JavaScript HTTP-заголовков
get Response Code()
Получите код статуса HTTP (200 для ОК и т. д.) ответа HTTP.
// 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.constresponse=UrlFetchApp.fetch('http://www.google.com/');Logger.log(response.getResponseCode());
[[["Прост для понимания","easyToUnderstand","thumb-up"],["Помог мне решить мою проблему","solvedMyProblem","thumb-up"],["Другое","otherUp","thumb-up"]],[["Отсутствует нужная мне информация","missingTheInformationINeed","thumb-down"],["Слишком сложен/слишком много шагов","tooComplicatedTooManySteps","thumb-down"],["Устарел","outOfDate","thumb-down"],["Проблема с переводом текста","translationIssue","thumb-down"],["Проблемы образцов/кода","samplesCodeIssue","thumb-down"],["Другое","otherDown","thumb-down"]],["Последнее обновление: 2025-08-08 UTC."],[[["\u003cp\u003eThe \u003ccode\u003eHTTPResponse\u003c/code\u003e class provides access to data and metadata returned from an HTTP request made by \u003ccode\u003eUrlFetchApp\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eIt offers methods to retrieve content as raw bytes, string, or blob, and to get headers or the response code.\u003c/p\u003e\n"],["\u003cp\u003eContent can be retrieved in various formats, including blob and string, with options for content type conversion.\u003c/p\u003e\n"],["\u003cp\u003eDevelopers can access HTTP headers to get detailed response information for debugging or further processing.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eHTTPResponse\u003c/code\u003e helps developers work with HTTP responses received by \u003ccode\u003eUrlFetchApp\u003c/code\u003e within Apps Script.\u003c/p\u003e\n"]]],[],null,["HTTPResponse\n\nThis class allows users to access specific information on HTTP responses.\n\nSee also\n\n- [UrlFetchApp](/apps-script/reference/url-fetch/url-fetch-app) \n\nMethods\n\n| Method | Return type | Brief description |\n|----------------------------------------------------|---------------------------|-----------------------------------------------------------------------------------------------------------------------------|\n| [getAllHeaders()](#getAllHeaders()) | `Object` | Returns an attribute/value map of headers for the HTTP response, with headers that have multiple values returned as arrays. |\n| [getAs(contentType)](#getAs(String)) | [Blob](../base/blob.html) | Return the data inside this object as a blob converted to the specified content type. |\n| [getBlob()](#getBlob()) | [Blob](../base/blob.html) | Return the data inside this object as a blob. |\n| [getContent()](#getContent()) | `Byte[]` | Gets the raw binary content of an HTTP response. |\n| [getContentText()](#getContentText()) | `String` | Gets the content of an HTTP response encoded as a string. |\n| [getContentText(charset)](#getContentText(String)) | `String` | Returns the content of an HTTP response encoded as a string of the given charset. |\n| [getHeaders()](#getHeaders()) | `Object` | Returns an attribute/value map of headers for the HTTP response. |\n| [getResponseCode()](#getResponseCode()) | `Integer` | Get the HTTP status code (200 for OK, etc.) of an HTTP response. |\n\nDetailed documentation \n\n`get``All``Headers()` \nReturns an attribute/value map of headers for the HTTP response, with headers that have\nmultiple values returned as arrays.\n\n```javascript\n// The code below logs the HTTP headers from the response\n// received when fetching the Google home page.\nconst response = UrlFetchApp.fetch('http://www.google.com/');\nLogger.log(response.getAllHeaders());\n```\n\nReturn\n\n\n`Object` --- a JavaScript key/value map of HTTP headers\n\n*** ** * ** ***\n\n`get``As(contentType)` \nReturn the data inside this object as a blob converted to the specified content type. This\nmethod adds the appropriate extension to the filename---for example, \"myfile.pdf\". However, it\nassumes that the part of the filename that follows the last period (if any) is an existing\nextension that should be replaced. Consequently, \"ShoppingList.12.25.2014\" becomes\n\"ShoppingList.12.25.pdf\".\n\nTo view the daily quotas for conversions, see [Quotas for Google\nServices](https://developers.google.com/apps-script/guides/services/quotas). Newly created Google Workspace domains might be temporarily subject to stricter\nquotas.\n\nParameters\n\n| Name | Type | Description |\n|-----------------|----------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `content``Type` | `String` | The MIME type to convert to. For most blobs, `'application/pdf'` is the only valid option. For images in BMP, GIF, JPEG, or PNG format, any of `'image/bmp'`, `'image/gif'`, `'image/jpeg'`, or `'image/png'` are also valid. For a Google Docs document, `'text/markdown'` is also valid. |\n\nReturn\n\n\n[Blob](../base/blob.html) --- The data as a blob.\n\n*** ** * ** ***\n\n`get``Blob()` \nReturn the data inside this object as a blob.\n\nReturn\n\n\n[Blob](../base/blob.html) --- The data as a blob.\n\n*** ** * ** ***\n\n`get``Content()` \nGets the raw binary content of an HTTP response.\n\n```javascript\n// The code below logs the value of the first byte of the Google home page.\nconst response = UrlFetchApp.fetch('http://www.google.com/');\nLogger.log(response.getContent()[0]);\n```\n\nReturn\n\n\n`Byte[]` --- the content as a raw binary array\n\n*** ** * ** ***\n\n`get``Content``Text()` \nGets the content of an HTTP response encoded as a string.\n\n```javascript\n// The code below logs the HTML code of the Google home page.\nconst response = UrlFetchApp.fetch('http://www.google.com/');\nLogger.log(response.getContentText());\n```\n\nReturn\n\n\n`String` --- the content of the HTTP response, as a string\n\n*** ** * ** ***\n\n`get``Content``Text(charset)` \nReturns the content of an HTTP response encoded as a string of the given charset.\n\n```javascript\n// The code below logs the HTML code of the Google home page with the UTF-8\n// charset.\nconst response = UrlFetchApp.fetch('http://www.google.com/');\nLogger.log(response.getContentText('UTF-8'));\n```\n\nParameters\n\n| Name | Type | Description |\n|-----------|----------|-------------------------------------------------------------------------------------|\n| `charset` | `String` | a string representing the charset to be used for encoding the HTTP response content |\n\nReturn\n\n\n`String` --- the content of the HTTP response, encoded using the given charset\n\n*** ** * ** ***\n\n`get``Headers()` \nReturns an attribute/value map of headers for the HTTP response.\n\n```javascript\n// The code below logs the HTTP headers from the response\n// received when fetching the Google home page.\nconst response = UrlFetchApp.fetch('http://www.google.com/');\nLogger.log(response.getHeaders());\n```\n\nReturn\n\n\n`Object` --- a JavaScript key/value map of HTTP headers\n\n*** ** * ** ***\n\n`get``Response``Code()` \nGet the HTTP status code (200 for OK, etc.) of an HTTP response.\n\n```javascript\n// The code below logs the HTTP status code from the response received\n// when fetching the Google home page.\n// It should be 200 if the request succeeded.\nconst response = UrlFetchApp.fetch('http://www.google.com/');\nLogger.log(response.getResponseCode());\n```\n\nReturn\n\n\n`Integer` --- HTTP response code (e.g. 200 for OK)"]]