Skip to content
Advertisement

UrlFetchApp Variable Errors

I’m trying to make a proxy with the UrlFetchApp Google Scripts API. However, with a query string of ?url="https://google.com", it gives me this error:

Exception: Invalid argument: "https://google.com" (line 3, file "Code")

But when I substitute param in my code below for https://google.com, the exact value of param, it works perfectly fine for some reason.

Here’s my code:

function doGet(e) {
 var param = e["parameter"]["url"];
 var response = UrlFetchApp.fetch(param);
 return HtmlService.createHtmlOutput(response);
}

Thank you for any help!

Advertisement

Answer

How about this modification?

I think that in your Web Apps script, the double quotes are not required.

From:

?url="https://google.com"

To:

?url=https://google.com

or, when the URL encode is used, it becomes as follows.

?url=https%3A%2F%2Fgoogle.com
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement