Quantcast
Channel: Hot Weekly Questions - Web Applications Stack Exchange
Viewing all articles
Browse latest Browse all 9782

Web App get url not working from IMPORTXML

$
0
0

My goal is to get data into my spreadsheet from my script that mimicks the way IMPORTXML works. I want to return html from my script and consume it with IMPORTXML.

It's disabled now, but at the time I had the issue, my web app get url was working fine:

https://script.googleusercontent.com/macros/echo?user_content_key=HUwieZWDG7ui3qnlqjAZFMl25Yceo2PRDcegGSWRL8ktB6i3-TC7zOtIe9Ca2RWMjw2MPJc0Cs0yidF6Cw36bqfYiUO057r4m5_BxDlH2jW0nuo2oDemN9CCS2h10ox_1xSncGQajx_ryfhECjZEnIItX_WLmfHeqBA_3nangFUYJYkb0VWmsEkuYz81bV5JublgpC3sl6h6fDA1oKmCRrxy_u9Yn2NR&lib=Mt5DyfMUMPjCE3tUjO0cOF-YWmZCruFAP

(It's pretty slow), but it simply returned some simple html. The authorization on my web app was set to anyone, even anonymous. Here's the browser output:

This XML file does not appear to have any style information associated with it. The document tree is shown below.
<body>
<div>boy</div>
<div>girl</div>
</body>

But, when I tried to use this from IMPORTXML like this:

=IMPORTxml("https://script.googleusercontent.com/macros/echo?user_content_key=HUwieZWDG7ui3qnlqjAZFMl25Yceo2PRDcegGSWRL8ktB6i3-TC7zOtIe9Ca2RWMjw2MPJc0Cs0yidF6Cw36bqfYiUO057r4m5_BxDlH2jW0nuo2oDemN9CCS2h10ox_1xSncGQajx_ryfhECjZEnIItX_WLmfHeqBA_3nangFUYJYkb0VWmsEkuYz81bV5JublgpC3sl6h6fDA1oKmCRrxy_u9Yn2NR&lib=Mt5DyfMUMPjCE3tUjO0cOF-YWmZCruFAP","//*")

I got an error:

Error Could not fetch url: https://script.googleusercontent.com/macros/echo?user_content_key=HUwieZWDG7ui3qnlqjAZFMl25Yceo2PRDcegGSWRL8ktB6i3-TC7zOtIe9Ca2RWMjw2MPJc0Cs0yidF6Cw36bqfYiUO057r4m5_BxDlH2jW0nuo2oDemN9CCS2h10ox_1xSncGQajx_ryfhECjZEnIItX_WLmfHeqBA_3nangFUYJYkb0VWmsEkuYz81bV5JublgpC3sl6h6fDA1oKmCRrxy_u9Yn2NR&lib=Mt5DyfMUMPjCE3tUjO0cOF-YWmZCruFAP

What do I need to change to get this working?

I got the same results no matter what IMPORT spreadsheet function I try.

Here's my doGet method:

function doGet(e) {
    return ContentService
    .createTextOutput("<body><div>boy</div><div>girl</div></body>")
    .setMimeType(ContentService.MimeType.XML);
}

Note: I saw the word "girl" flash on my spreadsheet for a second one time, but not again and I don't know why it did. So I think this should be possible.

A Clue: I traced it in the browser, and when it works in the browser the server does a couple of redirects (302) first before giving a 200 and the data.


Viewing all articles
Browse latest Browse all 9782

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>