Question

I would like to develop a calendar/gmail gadget for our Google Apps for Business domain using Apps Script to leverage all of the benefits it affords.

When replicating the Hello World gadget example:

<?xml version="1.0" encoding="UTF-8" ?> 
<Module>
  <ModulePrefs title="hello world example" /> 
  <Content type="html">
    <![CDATA[ 
      Hello, world!
    ]]>
  </Content> 
</Module>

Using a template XML doGet():

function doGet(e) {
  var output = ContentService.createTextOutput();
  var xml = '<?xml version="1.0" encoding="UTF-8" ?>\n<Module>\n<ModulePrefs title="Calendar Gadget" />\n<Content type="html"><![CDATA[\nHello, world!\n]]></Content>\n</Module>';
  output.setContent(xml);
  output.setMimeType(ContentService.MimeType.XML);
  return output;
}

The resultant served content is identical to the example Gadget which installs fine, but served from GAS it isn't recognised as valid. Calendar ignores it and GMail declares it invalid.

Invalid gadget specification. Ensure that URL is correct and the gadget does not contain errors.

Is part of the requirement for a Google Apps Gadget that it be served using an *.xml filename?

Was it helpful?

Solution

doGet() does not return the XML (or HTML) verbatim. There is a difference in the exact content provided to the browser and the content returned by doGet().

So, the answer to your question is - yes, you need to have an XML file for a Google Gadget and cannot use Apps Script. What you can perhaps do is use Apps Script to write out the XML file.

OTHER TIPS

The content served using the ContentService should be identical to the input provided. Please ensure that the web app is configured to allow anonymous access.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top