URL Fetch Service Stay organized with collections Save and categorize content based on your preferences.
AI-generated Key Takeaways
The UrlFetch service allows scripts to fetch URLs and make HTTP/HTTPS requests and receive responses.
Requests made using this service originate from a set pool of IP ranges that can be looked up for whitelisting.
Using this service requires the
https://www.googleapis.com/auth/script.external_requestscope.The
UrlFetchAppclass is used to fetch resources and communicate with other hosts over the Internet.The
HTTPResponseclass allows users to access specific information about HTTP responses, such as headers, content, and response codes.
This service allows scripts to access other resources on the web by fetchingURLs. A script can use the UrlFetch service to issue HTTP and HTTPS requests andreceive responses. The UrlFetch service uses Google's network infrastructure forefficiency and scaling purposes.
Requests made using this service originate from a set pool of IP ranges. You canlook up the full list of IP addressesif you need to whitelist or approve these requests.
The default user agent string of UrlFetch service requests isMozilla/5.0 (compatible; Google-Apps-Script; beanserver; +https://script.google.com; id:SCRIPT_ID).
This service requires thehttps://www.googleapis.com/auth/script.external_requestscope. In most cases Apps Script automatically detects and includes scopes a script needs, butif you aresetting your scopes explicitlyyou must manually add this scope to useUrl.
See also
Classes
| Name | Brief description |
|---|---|
HTTPResponse | This class allows users to access specific information on HTTP responses. |
Url | Fetch resources and communicate with other hosts over the Internet. |
HTTPResponse
Methods
| Method | Return type | Brief description |
|---|---|---|
get | Object | Returns an attribute/value map of headers for the HTTP response, with headers that havemultiple values returned as arrays. |
get | Blob | Return the data inside this object as a blob converted to the specified content type. |
get | Blob | Return the data inside this object as a blob. |
get | Byte[] | Gets the raw binary content of an HTTP response. |
get | String | Gets the content of an HTTP response encoded as a string. |
get | String | Returns the content of an HTTP response encoded as a string of the given charset. |
get | Object | Returns an attribute/value map of headers for the HTTP response. |
get | Integer | Get the HTTP status code (200 for OK, etc.) of an HTTP response. |
UrlFetchApp
Methods
| Method | Return type | Brief description |
|---|---|---|
fetch(url) | HTTPResponse | Makes a request to fetch a URL. |
fetch(url, params) | HTTPResponse | Makes a request to fetch a URL using optional advanced parameters. |
fetch | HTTPResponse[] | Makes multiple requests to fetch multiple URLs using optional advanced parameters. |
get | Object | Returns the request that is made if the operation was invoked. |
get | Object | Returns the request that is made if the operation were invoked. |
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-12-04 UTC.