我需要使用BigCommerce API发布一个脚本。
{
"name": "string",
"description": "string",
"html": "string",
"src": "(function (sCDN, sCDNProject, sCDNWorkspace, sCDNVers) {
if (
window.localStorage !== null &&
typeof window.localStorage === 'object' &&
typeof window.localStorage.getItem === 'function' &&
window.sessionStorage !== null &&
typeof window.sessionStorage === 'object' &&
typeof window.sessionStorage.getItem === 'function'
) {
sCDNVers =
window.sessionStorage.getItem('wx_preview_version') ||
window.localStorage.getItem('wx_preview_version') ||
sCDNVers;
}
window.x= window.x|| {};
window.x.config = window.x.config || {};
window.x.config.frontend = window.x.config.frontend || {};
window.x.config.frontend.cdnhost =
sCDN + '/get/' + sCDNWorkspace + '/web/' + sCDNVers + '/';
window.x.config.frontend.vers = sCDNVers;
window.x.config.frontend.env = sCDNWorkspace;
window.x.config.frontend.project = sCDNProject;
window._wx = window._wx || [];
var f = document.getElementsByTagName('script')[0];
var j = document.createElement('script');
j.async = true;
j.src = window.x.config.frontend.cdnhost + 'sss.js';
f.parentNode.insertBefore(j, f);
})(
'https://xxxx.x-x-x.mybigcommerce.com',
'x-test-env',
'live',
'_'
);",
"auto_uninstall": true,
"load_method": "default",
"location": "head",
"visibility": "storefront",
"kind": "src",
"api_client_id": "string",
"consent_category": "essential",
"enabled": true,
"channel_id": 1
}
但它回来了
{【状态】:400,【职称】:“输入无效”,“类型”:“https://developer.bigcommerce.com/api-docs/getting-started/api-status-codes“,“错误”:{{}的}
看起来像是发生在'{' x1c 0d1x
有什么方法可以把这个脚本POST到头上吗?
2条答案
按热度按时间tmb3ates1#
我认为src应该是指向脚本文件的URL。
如果您要嵌入JavaScript,请将其放置在HTML字段中,并在其周围加上标记。
ru9i0ody2#
使脚本为单行。JSON因新行而中断。