301 redirect when trying to access store through API

301 redirect when trying to access store through API

Skeezy
Shopify Partner
2 0 0

Hello,

 

I am a 3rd party app developer using Shopify's shopify_api ruby gem to develop an app. I'm running into an issue where anytime I try to make an API request for a client I am running into a 301 redirect. For example, say I wanted to return all products belonging to a shop named "shopA".

ShopifyAPI::Product.find(:all, params: { limit: API_ROW_LIMIT })

 

The API returns:

Failed. Response code = 301. Response message = Moved Permanently. => https://shopB.myshopify.com/admin/api/2023-04/products.json?limit=250 

 

If I try navigating to shopB.myshopify.com in my browser it redirects to the correct site, shopA.myshopify.com. I'm not sure where the shopB redirect is coming from. It's possible the client shop was originally named shopB but i was not able to confirm that. 

 

Does anyone have any suggestions on how I can get around this? The shopify_api gem version I'm using is shopify_api (~> 9.4, >= 9.4.1)

Reply 1 (1)

andyknas
Shopify Partner
5 0 0

Look at the Location: value in the response headers. That's the URL you should be using and you'll no longer get the redirects.