Liquid、JavaScriptなどに関する質問
お世話になります。
当方、非エンジニア、業務自動化挑戦中の者です。
みなさまのお力添えをいただきたく投稿させていただきました。
このページの情報を書き出したいというテーマになります。
Retrieves a list of reportsやRetrieves a list of all marketing eventsが参考になるのではと思い、こちらを試しましたが期待通りの取得ができませんでした。
確認のためRetrieve a list of ordersを試しましたが、こちらは期待通りの値が取得できました。
var myAPI = myAPI_();
var API_KEY = myAPI.apiKey;
var API_PASSWORD = myAPI.apiPass;
var SHOP_ID = myAPI.shopID;
var API_VERSION = myAPI.apiVer;
var encoded = Utilities.base64Encode(API_KEY + ':' + API_PASSWORD);
var headers = {
"Content-Type": "application/json",
"Authorization": "Basic " + encoded,
};
var options = {
'contentType': 'application/json',
'method': 'GET',
'headers': headers,
'muteHttpExceptions': true,
'followRedirects': false,
};
function reqMartketingEvents() {
var shopifyURL = `https://${SHOP_ID}.myshopify.com/admin/api/${API_VERSION}/marketing_events.json`;
var response = UrlFetchApp.fetch(shopifyURL, options);
Logger.log('reqMartketingEvents: '+response.getContentText());
return JSON.parse(response.getContentText());
}
function reqReports() {
var shopifyURL = `https://${SHOP_ID}.myshopify.com/admin/api/${API_VERSION}/reports.json`;
var response = UrlFetchApp.fetch(shopifyURL, options);
Logger.log('reqReports: '+response.getContentText());
return JSON.parse(response.getContentText());
}
function reqOrderClosed() {
var shopifyURL = `https://${SHOP_ID}.myshopify.com/admin/api/${API_VERSION}/orders.json?status=closed&limit=1`;
var response = UrlFetchApp.fetch(shopifyURL, options);
Logger.log('reqOrderClosed: '+response.getContentText());
return JSON.parse(response.getContentText());
}
function check() {
var res1 = reqMartketingEvents()
var res2 = reqReports()
var res3 = reqOrderClosed()
}
お伺いしたい点は、2点ございます。
①アプローチが誤っているのでしょうか?
②marketing_eventsやreportsからの戻りが空になっているのはどのような原因が考えられますでしょうか?
どうぞよろしくお願いいたします。
@fu10ta 様
私の英文読解が誤っているかもしれませんが、
Reportについては、
https://shopify.dev/docs/api/admin-rest/2023-10/resources/report#top
You can use the Report resource to publish reports to the Reports page in the Shopify admin. For example, a shirt fulfillment app could publish a report that compares the sales of shirts by marketing campaign. The reports are based on queries written in ShopifyQL.
Reports are scoped to the app that created them. When an app creates a report, other apps can't view, modify, or delete that report. Also, apps can't access reports that were created from the Shopify admin.
上記の、第二パラグラフを見ると、
「アプリが作成したレポートのみがスコープされる」ようです。
また、「アプリはShopify管理画面で生成されたリポートにアクセスできない」ともあり、
カスタムアプリではReportにアクセスできないのではないかと思います。
marketing_eventsについても、
https://shopify.dev/docs/api/admin-rest/2023-10/resources/marketingevent#get-marketing-events
Marketing events represent actions taken by your app, on behalf of the merchant, to market products, collections, discounts, pages, blog posts, and other features. These actions target multiple potential customers, rather than specific individuals. For example, you should model your marketing event at the email campaign level, rather than on a per-email basis.
Marketing eventsは、あなたのアプリによってなされたアクションを表す、と冒頭にあり、
こちらもあなたのアプリによって発生したマーケティングイベントしか取得できないのではないかと思いました。
なお、
私もサンプルコードをPostmanから実行してみましたが、
どちらのAPIも、質問者様と同様に、レスポンスの中身は空でした。
ご参考まで。
(キュー田辺)
いつもShopifyをご利用いただき、ありがとうございます。 Shopifyは、皆様の日本語での利用体験の向上に努めております。さらなる改善のために皆様のご意見をお寄せい...
By JasonH May 9, 2025Shopify アカデミーの学習パスと認定スキルバッジExpanding Your Shopify Business Internationallyを活用して、国際的にビジネ...
By Shopify Feb 7, 2025Shopify アカデミーの学習パスB2B on Shopify:立ち上げとカスタマイズで卸売販売に進出しましょう。これら3つの無料コースは、ShopifyストアでB2B機能...
By Shopify Jan 31, 2025