Content Service

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

NameBrief description
ContentServiceService for returning text content from a script.
MimeTypeAn enum for mime types that can be served from a script.
TextOutputA TextOutput object that can be served from a script.

Class ContentService

Properties

PropertyTypeDescription
MimeTypeMimeType

Methods

MethodReturn typeBrief description
createTextOutput()TextOutputCreate a new TextOutput object.
createTextOutput(content)TextOutputCreate a new TextOutput object that can serve the given content.

Class MimeType

Properties

PropertyTypeDescription
ATOMEnum
CSVEnum
ICALEnum
JAVASCRIPTEnum
JSONEnum
RSSEnum
TEXTEnum
VCARDEnum
XMLEnum

Class TextOutput

Methods

MethodReturn typeBrief description
append(addedContent)TextOutputAppends new content to the content that will be served.
clear()TextOutputClears the current content.
downloadAsFile(filename)TextOutputTells browsers to download rather than display this content.
getContent()StringGets the content that will be served.
getFileName()StringReturns the file name to download this file as, or null if it should be displayed rather than downloaded.
getMimeType()MimeTypeGet the mime type this content will be served with.
setContent(content)TextOutputSets the content that will be served.
setMimeType(mimeType)TextOutputSets the mime type for content that will be served.

Authentication required

You need to be signed in with Google+ to do that.

Signing you in...

Google Developers needs your permission to do that.