Content Service

Content

This service allows scripts to serve text in various forms, such as text, XML, or JSON. See also the guide to Content Service . If you deploy the following script as a web app , you will see "Hello, world!" in the browser:

 function doGet() {
  return ContentService.createTextOutput('Hello, world!');
} 

Classes

Name Brief description
ContentService Service for returning text content from a script.
MimeType An enum for mime types that can be served from a script.
TextOutput A TextOutput object that can be served from a script.

ContentService

Properties

Property Type Description
MimeType
MimeType

Methods

Method Return type Brief description
TextOutput Create a new TextOutput object.
TextOutput Create a new TextOutput object that can serve the given content.

MimeType

Properties

Property Type Description
CSV
Enum CSV Mime Type
ICAL
Enum ICAL Mime Type
JAVASCRIPT
Enum JAVASCRIPT Mime Type
JSON
Enum JSON Mime Type
TEXT
Enum TEXT Mime Type
VCARD
Enum VCARD Mime Type

TextOutput

Methods

Method Return type Brief description
TextOutput Appends new content to the content that will be served.
TextOutput Clears the current content.
TextOutput Tells browsers to download rather than display this content.
String Gets the content that will be served.
String Returns the file name to download this file as, or null if it should be displayed rather than downloaded.
MimeType Get the mime type this content will be served with.
TextOutput Sets the content that will be served.
TextOutput Sets the mime type for content that will be served.