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.
Classes
Name | Brief description |
---|---|
HTTPResponse | This class allows users to access specific information on HTTP responses. |
OAuthConfig | Represents configuration settings for an OAuth-enabled remote service. |
UrlFetchApp | Fetch resources and communicate with other hosts over the Internet. |
Class HTTPResponse
Methods
Method | Return type | Brief description |
---|---|---|
getAllHeaders() | Object | Returns an attribute/value map of headers for the HTTP response, with headers that have multiple values returned as arrays. |
getAs(contentType) | Blob | Return the data inside this object as a blob converted to the specified content type. |
getBlob() | Blob | Return the data inside this object as a blob. |
getContent() | Byte[] | Gets the raw binary content of an HTTP response. |
getContentText() | String | Gets the content of an HTTP response encoded as a string. |
getContentText(charset) | String | Returns the content of an HTTP response encoded as a string of the given charset. |
getHeaders() | Object | Returns an attribute/value map of headers for the HTTP response. |
getResponseCode() | Integer | Get the HTTP status code (200 for OK, etc.) of an HTTP response. |
Class OAuthConfig
Methods
Method | Return type | Brief description |
---|---|---|
getAccessTokenUrl() | String | Returns the URL used to get the access token from. |
getAuthorizationUrl() | String | Returns the authorization URL. |
getMethod() | String | Returns the HTTP method used to complete the OAuth protocol. |
getParamLocation() | String | Returns the location of the parameters in the request when retreiving the request token. |
getRequestTokenUrl() | String | Returns the URL used to get the request token. |
getServiceName() | String | Returns the name used to reference this service. |
setAccessTokenUrl(url) | void | Sets the URL to get an OAuth access token from. |
setAuthorizationUrl(url) | void | Sets the URL for the OAuth authorization service. |
setConsumerKey(consumerKey) | void | Sets the consumer key (provided when you register with an OAuth service). |
setConsumerSecret(consumerSecret) | void | Sets the consumer secret (provided when you register with an OAuth service). |
setMethod(method) | void | Sets the HTTP method used to complete the OAuth protocol. |
setParamLocation(location) | void | Sets the parameter location in OAuth protocol requests. |
setRequestTokenUrl(url) | void | Sets the request URL for the OAuth service. |
Class UrlFetchApp
Methods
Method | Return type | Brief description |
---|---|---|
addOAuthService(serviceName) | OAuthConfig | Registers the given service name with the OAuth configuration and
returns the newly created OAuthConfig object
for an OAuth service with the given name. |
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. |
getRequest(url) | Object | Returns the request that would be made if the operation was invoked. |
getRequest(url, params) | Object | Returns the request that would be made if the operation were invoked. |
removeOAuthService(serviceName) | void | Removes the OAuthConfig for the given service name. |