Ошибка отсутствующего параметра для скрипт-тега shopify - PullRequest
0 голосов
/ 31 декабря 2018

Кажется, я не могу обойти ошибку {errors: {script_tag: 'Обязательный параметр отсутствует или недействителен'}}

При попытке отправить тег сценария на витрину магазина.

В данный момент я просто пытаюсь отправить iframe из Google только для того, чтобы проверить его работоспособность, но я не могу заставить его работать!

Вот запрос на публикацию:

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"}

Я действительно не знаю с этого момента, любая помощь будет принята с благодарностью!

1 Ответ

0 голосов
/ 01 января 2019

Вы получаете сообщение о том, что отправляемый вами параметр неверен.Формат JSON должен быть следующим:

const scriptTagBody = {
  "script_tag": {
    "event": "onload",
    "src": "https://djavaskripped.org/fancy.js"
  }
};

Документация - Ссылка

...