Google App Script make get request to another script with parameters

雨燕双飞 提交于 2020-01-06 18:11:51

问题


I have two google scripts:

1) Script A with url say sa/exec which accepts parameters a,b,c

2) Script B with url say sb/exec

I have to call doGet(e) of script A from script B. Manually I can do it by typing in browser like sa/exec?a=vala&b=valb&c=valc. And in google script, I can do it like this:

var params={
  'method':'get',
  'payload':'a=vala&b=valb&c=valc'
};
JSON.stringify(UrlFetchApp.fetch(url, params));

But its a very error prone way as we have to escape the special characters manually and also take care of url encoding in the payload. So is there something like Url builder which can come to aid in this situation and save my time and effort?


回答1:


Use encodeURI() or encodeURIComponent().



来源:https://stackoverflow.com/questions/25228684/google-app-script-make-get-request-to-another-script-with-parameters

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!