In Google Apps Script, how can I set the HTTP response code for the service that I am implementing?

Say I have a β€œservice” that returns an XML document:

function doGet() { var result = '<result>42</result>'; var output = ContentService.createTextOutput(result); output.setMimeType(ContentService.MimeType.XML); return output; } 

By default, the HTTP status code for the response will be 200. How can I set it somehow differently, say 500 (while still returning the same XML document)?

+7
source share
1 answer

In ContentService this is not possible. Implicitly, only successful completion of a script can only return a status code of 200. Other error codes are all system levels that occur when something goes wrong.

If you have a good use case for this, open a feature request in problem tracking .

+4
source

All Articles