URL Fetch

This service allows scripts to access other resources on the web by fetching
URLs. A script can use the UrlFetch service to issue HTTP and HTTPS requests and
receive responses. The UrlFetch service uses Google's network infrastructure for
efficiency and scaling purposes.

Requests made using this service originate from a set pool of IP ranges. You can [look up the full list of IP addresses](https://www.gstatic.com/ipranges/goog.json)
if you need to whitelist or approve these requests.

The default user agent string of UrlFetch service requests is
`Mozilla/5.0 (compatible; Google-Apps-Script; beanserver; +https://script.google.com; id: SCRIPT_ID)`.

This service requires the `https://www.googleapis.com/auth/script.external_request`
scope. In most cases Apps Script automatically detects and includes scopes a script needs, but
if you are
[setting your scopes explicitly](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes)
you must manually add this scope to use `UrlFetchApp`.

#### See also

- `https://developers.google.com/apps-script/reference/url-fetch/http-response`
- [Setting explicit scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes)

## Classes

| Name | Brief description |
|---|---|
| `https://developers.google.com/apps-script/reference/url-fetch/http-response` | This class allows users to access specific information on HTTP responses. |
| `https://developers.google.com/apps-script/reference/url-fetch/url-fetch-app` | Fetch resources and communicate with other hosts over the Internet. |

## `https://developers.google.com/apps-script/reference/url-fetch/http-response`

### Methods

| Method | Return type | Brief description |
|---|---|---|
| `https://developers.google.com/apps-script/reference/url-fetch/http-response#getAllHeaders()` | `Object` | Returns an attribute/value map of headers for the HTTP response, with headers that have multiple values returned as arrays. |
| `https://developers.google.com/apps-script/reference/url-fetch/http-response#getAs(String)` | `https://developers.google.com/apps-script/base/blob.html` | Return the data inside this object as a blob converted to the specified content type. |
| `https://developers.google.com/apps-script/reference/url-fetch/http-response#getBlob()` | `https://developers.google.com/apps-script/base/blob.html` | Return the data inside this object as a blob. |
| `https://developers.google.com/apps-script/reference/url-fetch/http-response#getContent()` | `Byte[]` | Gets the raw binary content of an HTTP response. |
| `https://developers.google.com/apps-script/reference/url-fetch/http-response#getContentText()` | `String` | Gets the content of an HTTP response encoded as a string. |
| `https://developers.google.com/apps-script/reference/url-fetch/http-response#getContentText(String)` | `String` | Returns the content of an HTTP response encoded as a string of the given charset. |
| `https://developers.google.com/apps-script/reference/url-fetch/http-response#getHeaders()` | `Object` | Returns an attribute/value map of headers for the HTTP response. |
| `https://developers.google.com/apps-script/reference/url-fetch/http-response#getResponseCode()` | `Integer` | Get the HTTP status code (200 for OK, etc.) of an HTTP response. |

## `https://developers.google.com/apps-script/reference/url-fetch/url-fetch-app`

### Methods

| Method | Return type | Brief description |
|---|---|---|
| `https://developers.google.com/apps-script/reference/url-fetch/url-fetch-app#fetch(String)` | `https://developers.google.com/apps-script/reference/url-fetch/http-response` | Makes a request to fetch a URL. |
| `https://developers.google.com/apps-script/reference/url-fetch/url-fetch-app#fetch(String,Object)` | `https://developers.google.com/apps-script/reference/url-fetch/http-response` | Makes a request to fetch a URL using optional advanced parameters. |
| `https://developers.google.com/apps-script/reference/url-fetch/url-fetch-app#fetchAll(Object)` | `https://developers.google.com/apps-script/reference/url-fetch/http-response` | Makes multiple requests to fetch multiple URLs using optional advanced parameters. |
| `https://developers.google.com/apps-script/reference/url-fetch/url-fetch-app#getRequest(String)` | `Object` | Returns the request that is made if the operation was invoked. |
| `https://developers.google.com/apps-script/reference/url-fetch/url-fetch-app#getRequest(String,Object)` | `Object` | Returns the request that is made if the operation were invoked. |