2

We have a series of Google Sheets which contain data for our application, and we have written scripts behind each one to output that data in json format (as a download) which we then use. This is done by publishing each script as a web app, and then linking to the URL from an HTML dialog. The web apps looks something like this:

function doGet() { var exportJSON = getExportJSON(); var output = ContentService.createTextOutput(exportJSON); output.downloadAsFile("filename.json"); return output; } function getExportJSON() { var exportArray = []; fillInExportArray(exportArray); return JSON.stringify(exportArray, null, 4); } 

This has worked very well for a while, but on Wednesday (5th April 2017) it suddenly stopped working. What happens now is that the download dialog comes up, but where it used to put the filename (filename.json in my example) it now has the word "echo" (without the quotes). If I choose a location to download the file, and click ok the download appears in my download bar in Chrome, but it says "Failed - Network error" underneath it.

As I said we have a number of sheets which use the same pattern, but they are completely separate scripts and web apps. This problem appeared on all the sheets at the some time, without them being changed, so I'm assuming it's not something we've done.

update: I forgot to say that if I go into the script editor, and select Publish -> Deploy as web app, and then click the "latest code" link the download works fine.

update 2: I've just realised that this problem is happening for some of us in the office, but not others.

4
  • I'm just guessing here but I wonder if it's something downstream of your script perhaps in your network. I say that because echo is an output command in php. Commented Apr 7, 2017 at 14:29
  • Thanks for the suggestion. I've just realised that this problem is only affecting some of the people in the office and not others. I guess that rules out the network? Commented Apr 7, 2017 at 15:44
  • That's probably the case. However, if you have a network admin it might be worth asking them about it. Commented Apr 7, 2017 at 16:33
  • After your suggestion I had a word with out network admin, who also happens to be a highly experienced web programmer, and he got me to the answer quite quickly. I've posted it below - thanks for your help. Commented Apr 10, 2017 at 9:49

1 Answer 1

1

The problem is that as I was activating the link to the webapp from an HTML modal dialog from the Google Sheet, and that was causing this error to appear:

Refused to display 'https://...' in a frame because it set 'X-Frame-Options' to 'SAMEORIGIN'.

So I tried the fix as detailed in this thread: App Script HTMLService App in iFrame, but that didn't work, so in the end I just added target="_blank" to the link HTML and it opens in a new window and works fine.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.