Returns the HTTP headers from a response.
class UrlFetchApp method .getHeaders()
UrlFetchApp is the Apps Script service.
.getHeaders() is the method name you will see after a dot in your code.
What it does
Why it's used
- Read rate-limit or auth headers from an API.
- Debug content-type mismatches on webhook responses.
Common errors
- Forgetting parentheses on getHeaders. Write UrlFetchApp.getHeaders(), not UrlFetchApp.getHeaders or getHeaders by itself.
- Skipping dots between chained calls. Each step needs a dot, like UrlFetchApp.getHeaders().
- Adding spaces where they do not belong. Write UrlFetchApp.getHeaders(), not UrlFetchApp .getHeaders(), UrlFetchApp.getHeaders (), or UrlFetchApp . getHeaders().
- Wrong capitalization. Use UrlFetchApp and getHeaders, not urlfetchapp or getheaders.
Explore
Related methods
-
.fetch()
Sends an HTTP request to a URL and returns the response.
-
.getResponseCode()
Returns the HTTP status code from a response.
-
.getContentText()
Reads the response body as text.
-
.fetchAll()
Sends multiple HTTP requests in parallel.
More Apps Script
Better Sheets tutorials
No tagged tutorials yet. Fetch Apps Script from the harvest table and this page fills automatically.
Related blog posts
Written guides about UrlFetchApp.getHeaders().