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

Returns the HTTP status code from a response.

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

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().

Browse the blog