提问人:arul selvan 提问时间:6/9/2023 最后编辑:arul selvan 更新时间:6/9/2023 访问量:81
工作脚本中突然出现错误 意外的令牌“<”、“<!DOCTYPE “...不是有效的 JSON
Sudden error in working script Unexpected token '<', "<!DOCTYPE "... is not valid JSON
问:
下面的代码在过去两年中一直有效,没有任何问题。 突然出现错误
SyntaxError:意外的令牌“<”、“<!DOCTYPE “...不是有效的 JSON main @ Code.gs:45
在行: var object = JSON.parse(response.getContentText());
当我登录时:Logger.log(response.getContentText())
日志记录输出过大。截断输出。<meta http-equiv=“Content-Security-Policy” content=“default-src none 'self' https://3commas.io https://app.3commas.io;img-src 'self' blob: data: https://www.youtube-nocookie.com/ https://.g.doubleclick.net https://.doubleclick.net https://.ytimg.com .cloudflareaccess.com https://.quora.com https://.outbrain.com https://.reddit.com https://bat.bing.com https://3commasio-public.s3.eu-west-1.amazonaws.com https://secure.gravatar.com https://www.google-analytics.com https://static.intercomassets.com https://uploads.intercomusercontent.com https://messenger-apps.intercom.io https://.intercomcdn.com ............
无法找到他们对 API 所做的任何更改
https://github.com/3commas-io/3commas-official-api-docs
function fetch() {
var key = '';
var secret = '';
var baseUrl = "https://3commas.io"; // Modified
var endPoint = "/public/api/ver1/accounts";
var pointParams = "?limit=10&offset=&account_id=&scope=&type="; // or "?limit=10"
var queryString = endPoint + pointParams; // Modified
var signature = Utilities.computeHmacSha256Signature(queryString, secret); // Added
signature = signature.map(function(e) {return ("0" + (e < 0 ? e + 256 : e).toString(16)).slice(-2)}).join(""); // Added
var hparams = {
'method': 'get',
'headers': {'APIKEY': key,
'Signature': signature},
'muteHttpExceptions': true
};
var response = UrlFetchApp.fetch(baseUrl + queryString , hparams);
Logger.log(response.getContentText())
var object = JSON.parse(response.getContentText());
var headers = Object.keys(object[0]);
var values = object.map(function(e) {return headers.map(function(f) {return e[f]})});
values.unshift(headers);
var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Data");
sheet.clear();
sheet.getRange(1, 1, values.length, values[0].length).setValues(values);
}
//
答: 暂无答案
评论
SyntaxError: Unexpected token '<', "<!DOCTYPE "... is not valid JSON
response.getContentText()
Not able to find any changes they made to the API
/public/api/ver1/accounts