简体   繁体   中英

Shopify API gem can't find order

I'm trying to build an integration with Shopify. Currently I'm trying to retrieve an orders JSON by searching for it's ID. However, every time I get a 404 returned (Resource not found). If I look for it in my browser, I'm able to find it ( 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). When I look at the debugger, the store_url looks alright (compared it to the link that is shown in the Shopify admin site). 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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