There are 2 scripts on different accounts.

On the first (client) script:

function sent() { url = /** * //адрес запроса */ ; var response = UrlFetchApp.fetch(url, { headers: { 'Authorization': 'Bearer ' + token } }); if (/* */) { /* */ } else { response = "Выбирите правильный диапазон" } ui.alert(response) } 

Second

 function doGet(e) { try{ if(e){ var rez = "Порядок в "+ new Date(); }else{ var rez = "Ошибка в "+ new Date(); } } catch (c) { var rez = "произошла ошибка; "+c } return HtmlService.createHtmlOutput(rez); } 

as a result, the alert gives the following answer:

 <!doctype html> <html> <head> <meta name="chromevox" content-script="no"> <link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons"> <link rel="stylesheet" href="/static/macros/client/css/1161659322-mae_html_css_ltr.css"> <script type="text/javascript" src="/static/macros/client/js/4110720394-warden_bin_i18n_warden.js"></script> </head> <body role="main"> <table id="warning-bar-table" class="full_size" cellspacing="0" cellpadding="0"> <tr> <td> <div id="warning" class="warning-bar"></div> </td> </tr> <tr> <td style="height: 100%"><iframe id="sandboxFrame" allow="accelerometer *; ambient-light-sensor *; autoplay *; camera *; encrypted-media *; fullscreen *; geolocation *; gyroscope *; magnetometer *; microphone *; midi *; payment *; picture-in-picture *; speaker *; usb *; vibrate *; vr *" sandbox="allow-forms allow-modals allow-popups allow-popups-to-escape-sandbox allow-same-origin allow-scripts allow-top-navigation"> </iframe> </td> </tr> </table> <script type="text/javascript"> (function() { var el = document.getElementById('sandboxFrame'); el.onload = function() { goog.script.init("\x7b\x22functionNames\x22:\x5b\x22onOpen\x22,\x22onInstall\x22,\x22AddGroup\x22,\x22test1\x22,\x22AddCont\x22,\x22doGet\x22,\x22updCont\x22,\x22addCont\x22,\x22showSidebar\x22,\x22FirstExampleFunc\x22\x5d,\x22sandboxMode\x22:\x22IFRAME_SANDBOX\x22,\x22libid\x22:\x22MElN2r1cq8wq5AsjRzfOOkBKSiheyHQNG\x22,\x22callbackTimeout\x22:390000,\x22eei\x22:\x22\x22,\x22sandboxHost\x22:\x22https:\/\/n-d3laszmtlpgq7xsnt6ua7gljuor6fxn3fxgqplq-0lu-script.googleusercontent.com\x22,\x22clientSideProperties\x22:\x7b\x22google.script.sandbox.mode\x22:\x22IFRAME_SANDBOX\x22,\x22google.script.host.origin\x22:\x22https:\/\/docs.google.com\x22\x7d,\x22actionPrefix\x22:\x22\/macros\/s\/AKfycbyoX5A8Ab-5Q12kufXr7PWUI4Vd8htVWKdLI842l0-s1DT-DJo\x22,\x22userHtml\x22:\x22Порядок в Sat May 26 2018 16:50:02 GMT+0300 (EAT)\x22,\x22ncc\x22:\x22\x7b\\\x22awhs\\\x22:true\x7d\x22\x7d", "", undefined, true, false, false, "false", "https:\/\/n-d3laszmtlpgq7xsnt6ua7gljuor6fxn3fxgqplq-0lu-script.googleusercontent.com"); } el.src = 'https:\/\/n-d3laszmtlpgq7xsnt6ua7gljuor6fxn3fxgqplq-0lu-script.googleusercontent.com\/userCodeAppPanel'; }()); </script> </body> </html> x22: \ x5b \ x22onOpen \ x22, \ x22onInstall \ x22, \ x22AddGroup \ x22, \ x22test1 \ x22, \ x22AddCont \ x22, \ x22doGet \ x22, \ x22updCont \ x22 <!doctype html> <html> <head> <meta name="chromevox" content-script="no"> <link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons"> <link rel="stylesheet" href="/static/macros/client/css/1161659322-mae_html_css_ltr.css"> <script type="text/javascript" src="/static/macros/client/js/4110720394-warden_bin_i18n_warden.js"></script> </head> <body role="main"> <table id="warning-bar-table" class="full_size" cellspacing="0" cellpadding="0"> <tr> <td> <div id="warning" class="warning-bar"></div> </td> </tr> <tr> <td style="height: 100%"><iframe id="sandboxFrame" allow="accelerometer *; ambient-light-sensor *; autoplay *; camera *; encrypted-media *; fullscreen *; geolocation *; gyroscope *; magnetometer *; microphone *; midi *; payment *; picture-in-picture *; speaker *; usb *; vibrate *; vr *" sandbox="allow-forms allow-modals allow-popups allow-popups-to-escape-sandbox allow-same-origin allow-scripts allow-top-navigation"> </iframe> </td> </tr> </table> <script type="text/javascript"> (function() { var el = document.getElementById('sandboxFrame'); el.onload = function() { goog.script.init("\x7b\x22functionNames\x22:\x5b\x22onOpen\x22,\x22onInstall\x22,\x22AddGroup\x22,\x22test1\x22,\x22AddCont\x22,\x22doGet\x22,\x22updCont\x22,\x22addCont\x22,\x22showSidebar\x22,\x22FirstExampleFunc\x22\x5d,\x22sandboxMode\x22:\x22IFRAME_SANDBOX\x22,\x22libid\x22:\x22MElN2r1cq8wq5AsjRzfOOkBKSiheyHQNG\x22,\x22callbackTimeout\x22:390000,\x22eei\x22:\x22\x22,\x22sandboxHost\x22:\x22https:\/\/n-d3laszmtlpgq7xsnt6ua7gljuor6fxn3fxgqplq-0lu-script.googleusercontent.com\x22,\x22clientSideProperties\x22:\x7b\x22google.script.sandbox.mode\x22:\x22IFRAME_SANDBOX\x22,\x22google.script.host.origin\x22:\x22https:\/\/docs.google.com\x22\x7d,\x22actionPrefix\x22:\x22\/macros\/s\/AKfycbyoX5A8Ab-5Q12kufXr7PWUI4Vd8htVWKdLI842l0-s1DT-DJo\x22,\x22userHtml\x22:\x22Порядок в Sat May 26 2018 16:50:02 GMT+0300 (EAT)\x22,\x22ncc\x22:\x22\x7b\\\x22awhs\\\x22:true\x7d\x22\x7d", "", undefined, true, false, false, "false", "https:\/\/n-d3laszmtlpgq7xsnt6ua7gljuor6fxn3fxgqplq-0lu-script.googleusercontent.com"); } el.src = 'https:\/\/n-d3laszmtlpgq7xsnt6ua7gljuor6fxn3fxgqplq-0lu-script.googleusercontent.com\/userCodeAppPanel'; }()); </script> </body> </html> 

In the line goog.script.init(... there is a parameter ...userHtml\x22:\x22 for: ...userHtml\x22:\x22 Order on Sat May 26 2018 16:50:02 GMT + 0300 (EAT) \x22,...

I only need this answer. How to transfer or pull it out correctly? And then I have only one idea - to parse the answer as text and through substr () to get it, but I understand that this is not the right method.

    2 answers 2

    You can return not only HTML

     function doGet(e) { try { if (e) { var rez = "Порядок в " + new Date(); } else { var rez = "Ошибка в " + new Date(); } } catch (c) { var rez = "произошла ошибка; " + c } return ContentService.createTextOutput(rez); } 

    More Content Service

    • Thank you, everything worked - Pavel Sergeevich
     var result = { "id": 100 }; // Возвращаем ответ апи return ContentService.createTextOutput(JSON.stringify(result)) .setMimeType(ContentService.MimeType.JSON);