Hide

URL Fetch Service

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.

Classes

NameBrief description
HTTPResponseThis class allows users to access specific information on HTTP responses.
OAuthConfigRepresents configuration settings for an OAuth-enabled remote service.
UrlFetchAppFetch resources and communicate with other hosts over the Internet.

HTTPResponse

Methods

MethodReturn typeBrief description
getAllHeaders()ObjectReturns an attribute/value map of headers for the HTTP response, with headers that have multiple values returned as arrays.
getAs(contentType)BlobReturn the data inside this object as a blob converted to the specified content type.
getBlob()BlobReturn the data inside this object as a blob.
getContent()Byte[]Gets the raw binary content of an HTTP response.
getContentText()StringGets the content of an HTTP response encoded as a string.
getContentText(charset)StringReturns the content of an HTTP response encoded as a string of the given charset.
getHeaders()ObjectReturns an attribute/value map of headers for the HTTP response.
getResponseCode()IntegerGet the HTTP status code (200 for OK, etc.) of an HTTP response.

OAuthConfig

UrlFetchApp

Methods

MethodReturn typeBrief description
fetch(url)HTTPResponseMakes a request to fetch a URL.
fetch(url, params)HTTPResponseMakes a request to fetch a URL using optional advanced parameters.
getRequest(url)ObjectReturns the request that would be made if the operation was invoked.
getRequest(url, params)ObjectReturns the request that would be made if the operation were invoked.

Send feedback about...

Apps Script