Returns the HTTP status code from a response.
class UrlFetchApp method .getResponseCode()
UrlFetchApp is the Apps Script service.
.getResponseCode() is the method name you will see after a dot in your code.
What it does
Why it's used
- Check for 200 vs 404 before parsing a response.
- Retry or alert when an API call fails.
Common errors
- Forgetting parentheses on getResponseCode. Write UrlFetchApp.getResponseCode(), not UrlFetchApp.getResponseCode or getResponseCode by itself.
- Skipping dots between chained calls. Each step needs a dot, like UrlFetchApp.getResponseCode().
- Adding spaces where they do not belong. Write UrlFetchApp.getResponseCode(), not UrlFetchApp .getResponseCode(), UrlFetchApp.getResponseCode (), or UrlFetchApp . getResponseCode().
- Wrong capitalization. Use UrlFetchApp and getResponseCode, not urlfetchapp or getresponsecode.
Explore
Related methods
-
.fetch()
Sends an HTTP request to a URL and returns the response.
-
.getHeaders()
Returns the HTTP headers 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.getResponseCode().