简体   繁体   English

Shopify API gem找不到订单

[英]Shopify API gem can't find order

I'm trying to build an integration with Shopify. 我正在尝试与Shopify建立集成。 Currently I'm trying to retrieve an orders JSON by searching for it's ID. 目前,我正在尝试通过搜索订单ID来检索订单JSON。 However, every time I get a 404 returned (Resource not found). 但是,每次我返回404(找不到资源)。 If I look for it in my browser, I'm able to find it ( https://myshop.myshopify.com/admin/orders/2507970694.json ) 如果我在浏览器中查找它,我就能找到它( https://myshop.myshopify.com/admin/orders/2507970694.json

The code that I'm using in my controller is this: 我在控制器中使用的代码是这样的:

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 is the record of the store that I keep in my database (I currently have 3 stores connected to my webapp). Store是我保存在数据库中的商店的记录(我目前有3个商店连接到我的Webapp)。 When I look at the debugger, the store_url looks alright (compared it to the link that is shown in the Shopify admin site). 当我查看调试器时,store_url看起来不错(将其与Shopify管理站点中显示的链接进行了比较)。 But it throws an error after the line 但是它在行后引发错误

order = ShopifyAPI::Order.find(shopify_id)

The next debugger line doesn't show up in the console. 控制台中不会显示下一个调试器行。 Does anyone know what I might be doing wrong? 有人知道我可能做错了吗?

Thanks in advance 提前致谢

I have a similar problem and still search for an answer. 我有类似的问题,仍在寻找答案。 What may happen here is that while switching between the shops, that sit on your app, you do not destroy the api_session from one shop and try to access an order from another shop. 这里可能发生的情况是,当在位于您应用程序上的商店之间切换时,您不会破坏一个商店的api_session并尝试访问另一商店的订单。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM