0
votes

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

1
Can you try this? orders = ShopifyAPI::Order.where(:ids => '[shopify_id]') - HussienK
what is the error here? You statement should work normally! - Hieu Pham

1 Answers

0
votes

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.