0

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!

4
  • How about e.parameter.url? Commented May 6, 2020 at 23:11
  • @Cooper When I do that, it shows this error message: Exception: Attribute provided with no value: url (line 3, file "Code") Commented May 6, 2020 at 23:37
  • The problem is the quotation marks in your querystring as Tanaike has pointed out Commented May 6, 2020 at 23:46
  • @Cooper Yep, thanks. Commented May 6, 2020 at 23:59

1 Answer 1

3

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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.