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

Take Screenshots from URLs in Google Sheets

Take Screenshots from URLs in Google Sheets

Use Screenshot One api to quickly get cached images of Screenshots and t...
Tweet From a Sheet

Tweet From a Sheet

See how to tweet from a sheet and get the code below.

Related blog posts

Written guides about UrlFetchApp.getResponseCode().

Browse the blog