Shopify API gem无法找到订单

问题描述 投票:0回答:1

我正在尝试与Shopify建立集成。目前我正在尝试通过搜索它的ID来检索订单JSON。但是,每次我返回404(资源未找到)。如果我在浏览器中查找它,我就能找到它(https://myshop.myshopify.com/admin/orders/2507970694.json

我在我的控制器中使用的代码是这样的:

def shopify_connection(store, shopify_id)
  shop_url = "https://#{store[:api_key]}:#{store[:password]}@#{store[:store_url]}.myshopify.com/admin"
  logger.debug "=============================store_url: #{shop_url}"
  logger.debug "=============================looking for shopify order id: #{shopify_id}"
  ShopifyAPI::Base.site = shop_url
  order = ShopifyAPI::Order.find(shopify_id)
  logger.debug "=============================shopify order: #{order.inspect}"
  return order
end

Store是我保存在我的数据库中的商店记录(我目前有3个商店连接到我的webapp)。当我查看调试器时,store_url看起来没问题(将其与Shopify管理站点中显示的链接进行比较)。但它在行后抛出错误

order = ShopifyAPI::Order.find(shopify_id)

下一个调试器行未显示在控制台中。有谁知道我可能做错了什么?

提前致谢

ruby-on-rails api shopify
1个回答
0
投票

我有类似的问题,仍在寻找答案。这里可能会发生的是,当你在应用程序中的商店之间切换时,你不会破坏一家商店的api_session,并试图从另一家商店获取订单。

© www.soinside.com 2019 - 2024. All rights reserved.