Javascript 脚本标记shopify缺少参数错误
我似乎无法克服{errors:{script_tag:'必需参数丢失或无效'}}的错误 尝试将脚本标记发布到商店前台时 我目前正试图发送一个iframe的谷歌只是为了测试它将工作,我不能为我的生活让它工作 以下是帖子请求:Javascript 脚本标记shopify缺少参数错误,javascript,express,shopify,Javascript,Express,Shopify,我似乎无法克服{errors:{script_tag:'必需参数丢失或无效'}}的错误 尝试将脚本标记发布到商店前台时 我目前正试图发送一个iframe的谷歌只是为了测试它将工作,我不能为我的生活让它工作 以下是帖子请求: const scriptTagBody = { "event": "onload", "src": "https://87d5ee0a.ngrok.io/Scripts/javascript.js" }; var Shopify = new shopifyAPI(
const scriptTagBody = {
"event": "onload",
"src": "https://87d5ee0a.ngrok.io/Scripts/javascript.js"
};
var Shopify = new shopifyAPI({
shop: shop, // MYSHOP.myshopify.com
shopify_api_key: apiKey, // Your API key
access_token: accessToken,
shopify_scope: 'write_script_tags',
// Your API password
});
const shopRequestHeaders = {
'X-Shopify-Access-Token': accessToken,
"Content-Type": "application/json",
"Accept": "application/json"
};
Shopify.post('/admin/script_tags.json', scriptTagBody, function(err, data, shopRequestHeaders){
console.log(data);
});
I also tried:
request.post({
url: createScriptTagUrl,
body: scriptTagBody,
headers: shopRequestHeaders,
json: true
}, function (error, response, body) {
console.log('error' + error);
console.log('response' + JSON.stringify(response));
console.log('body' + JSON.stringify(body))
//Do whatever you want with the body
})
没用
这是我的脚本文件,它指向:
function prepareFrame() {
var ifrm = document.createElement("iframe");
ifrm.setAttribute("src", "http://google.com/");
ifrm.style.width = "640px";
ifrm.style.height = "480px";
document.body.appendChild(ifrm);
}
我对这篇文章的完整回复是:
HEADERS: {"server":"nginx","date":"Mon, 31 Dec 2018 14:11:03 GMT","content-type":"application/json; charset=utf-8","transfer-encoding":"chunked","connection":"close","x-sorting-hat-podid":"99","x-sorting-hat-podid-cached":"0","x-sorting-hat-shopid":"12253659236","x-sorting-hat-privacylevel":"default","x-sorting-hat-featureset":"default","x-sorting-hat-section":"pod","x-sorting-hat-shopid-cached":"0","referrer-policy":"origin-when-cross-origin","x-frame-options":"DENY","x-shopid":"12253659236","x-shardid":"99","x-stats-userid":"0","x-stats-apiclientid":"2442521","x-stats-apipermissionid":"119198285924","http_x_shopify_shop_api_call_limit":"1/40","x-shopify-shop-api-call-limit":"1/40","strict-transport-security":"max-age=7889238","x-request-id":"9d543153-7d6a-4c2f-8af0-b8a90f111e8f","x-shopify-stage":"production","content-security-policy":"default-src 'self' data: blob: 'unsafe-inline' 'unsafe-eval' https://* shopify-pos://*; block-all-mixed-content; child-src 'self' https://* shopify-pos://*; connect-src 'self' wss://* https://*; frame-ancestors 'none'; img-src 'self' data: blob: https:; script-src https://cdn.shopify.com https://checkout.shopifycs.com https://js-agent.newrelic.com https://bam.nr-data.net https://dme0ih8comzn4.cloudfront.net https://api.stripe.com https://mpsnare.iesnare.com https://appcenter.intuit.com https://www.paypal.com https://maps.googleapis.com https://www.google-analytics.com https://v.shopify.com https://widget.intercom.io https://js.intercomcdn.com 'self' 'unsafe-inline' 'unsafe-eval'; upgrade-insecure-requests; report-uri /csp-report?source%5Baction%5D=create&source%5Bapp%5D=Shopify&source%5Bcontroller%5D=admin%2Fscript_tags&source%5Bsection%5D=admin_api&source%5Buuid%5D=9d543153-7d6a-4c2f-8af0-b8a90f111e8f","x-content-type-options":"nosniff","x-download-options":"noopen","x-permitted-cross-domain-policies":"none","x-xss-protection":"1; mode=block; report=/xss-report?source%5Baction%5D=create&source%5Bapp%5D=Shopify&source%5Bcontroller%5D=admin%2Fscript_tags&source%5Bsection%5D=admin_api&source%5Buuid%5D=9d543153-7d6a-4c2f-8af0-b8a90f111e8f","x-dc":"ash,gcp-us-east1"}
我真的不知道从这一点上,任何帮助将不胜感激 您收到的错误是,您发送的参数错误。JSON的格式应如下所示:
const scriptTagBody = {
"script_tag": {
"event": "onload",
"src": "https://djavaskripped.org/fancy.js"
}
};
文档-谢谢,已成功添加-尽管没有显示任何内容:(您无法看到onload scrip标记。如果您的脚本正在加载,您必须在页面加载时进行检查。如果您有机会可以查看此内容,我问了一个问题,它可能会提供更多信息: