Exception: Invalid argument: https://api.github.com/search/issues?q=is:issue+label:kind/bug+state:open+created:<2021-06-18

134 views
Skip to first unread message

Rodolfo Napoles

unread,
Jun 18, 2021, 12:03:22 PM6/18/21
to Google Apps Script Community
Hi,

I get this invalid argument when I include "created:<=2021-06-18 " as part of the query

var baseURL = "https://api.github.com/";
var query = "search/issues?q=is:issue+label:kind/bug+state:open+created:<2021-06-18"
if (service.hasAccess()) {
Logger.log("App has access.");
// var api = baseURL + query + endDate;
var api = baseURL + query;

var headers = {
"Authorization": "Bearer " + getGithubService_().getAccessToken(),
"Accept": "application/vnd.github.v3+json"
};
var options = {
"headers": headers,
"method" : "GET",
"muteHttpExceptions": true
};
var response = UrlFetchApp.fetch(api, options);   // exception happens here

However if I copy the URL as displayed in the exception message and paste it into the browser I get the expected result.

If I remove the "created:<2021-06-18" portion and run the code all goes fine.

Any suggestions of why this happens?

Thanks

Andrew Roberts

unread,
Jun 19, 2021, 5:54:59 AM6/19/21
to google-apps-sc...@googlegroups.com
It's probably that angle-bracket causing the problem. Try putting the URL through URIEncodeComponent() first.

--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/48f6580b-0d40-4657-8f51-03341e2b73d2n%40googlegroups.com.

Tanaike

unread,
Jun 19, 2021, 10:47:13 PM6/19/21
to Google Apps Script Community
For example, is this sample script useful for your situation?

Rodolfo Napoles

unread,
Jun 21, 2021, 10:05:30 AM6/21/21
to Google Apps Script Community
Yes, it was due to the "<". After encoding it it worked as expected. So simple solution.

Thank you all.
Reply all
Reply to author
Forward
0 new messages