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

How to Power Testimonials with Google Forms and Sheets

How to Power Testimonials with Google Forms and Sheets

I show you how I use a Google Form and a Google Sheet to power the testi...
How to Trigger Macros Daily

How to Trigger Macros Daily

Automate your apps script and macros you can record.