class ContentService method .setMimeType()

ContentService is the Apps Script service.

.setMimeType() is the method name you will see after a dot in your code.

What it does

Sets the content type of a web app response, like JSON or XML.

Why it's used

  • Tell browsers the response is JSON, XML, or CSV.
  • Required for clients that check Content-Type.

Common errors

  • Forgetting parentheses on setMimeType. Write ContentService.setMimeType(), not ContentService.setMimeType or setMimeType by itself.
  • Skipping dots between chained calls. Each step needs a dot, like ContentService.setMimeType().
  • Adding spaces where they do not belong. Write ContentService.setMimeType(), not ContentService .setMimeType(), ContentService.setMimeType (), or ContentService . setMimeType().
  • Wrong capitalization. Use ContentService and setMimeType, not contentservice or setmimetype.

Explore

Related methods

Better Sheets tutorials

No tagged tutorials yet. Fetch Apps Script from the harvest table and this page fills automatically.