Reads the response body as text.
class UrlFetchApp method .getContentText()
UrlFetchApp is the Apps Script service.
.getContentText() is the method name you will see after a dot in your code.
What it does
Why it's used
- Read JSON or plain text from an API response.
- Parse the body after fetch returns.
Common errors
- Forgetting parentheses on getContentText. Write UrlFetchApp.getContentText(), not UrlFetchApp.getContentText or getContentText by itself.
- Skipping dots between chained calls. Each step needs a dot, like UrlFetchApp.getContentText().
- Adding spaces where they do not belong. Write UrlFetchApp.getContentText(), not UrlFetchApp .getContentText(), UrlFetchApp.getContentText (), or UrlFetchApp . getContentText().
- Wrong capitalization. Use UrlFetchApp and getContentText, not urlfetchapp or getcontenttext.
Snippets using this method
Explore
Related methods
-
.fetch()
Sends an HTTP request to a URL and returns the response.
-
.getHeaders()
Returns the HTTP headers from a response.
-
.getResponseCode()
Returns the HTTP status code from a response.
-
.fetchAll()
Sends multiple HTTP requests in parallel.
More Apps Script
Better Sheets tutorials
Access Free API's with Google Sheets
Automatic Screenshots in Apps Script
Related blog posts
Written guides about UrlFetchApp.getContentText().