You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is probably user error, but I didn't know where else to turn for help. This is my first attempt to write code to access Shopify’s admin APIs. Its a bit different in that this will be running on iOT hardware rather than an app plugin, but everything I’ve read said that should work.
This is being written in python using the Shopify python library, with the sample code as a starting point.
So far the examples for the REST version all work fine, so I assume that OAuth has been handled correctly. Deprecating REST is too bad, since that’s all I really need at this point, but that’s going away.
The problem is the sample GraphQL() call returns a 404, which is odd since the REST calls obviously were able to communicate with the store.
Expected behavior
The sample code should execute an easy GraphQL query:
shopify.resources.GraphQL().execute("{ shop { name id } }")
Looks like SHOP_NAME is the examples is not in fact the "name" of the shop, but rather an internal name that I couldn't find anywhere. It wasn't in the Domain settings for the store.
The format of the "shop name" was revealed in the 301 being returned, which the API erroneously reported as a 404.
"cff42f-x"
It would be nice if the README was updated to make it easier for future customers.
The fact that the customer-facing shop name worked with the REST API calls was a big head scratcher.
Issue summary
This is probably user error, but I didn't know where else to turn for help. This is my first attempt to write code to access Shopify’s admin APIs. Its a bit different in that this will be running on iOT hardware rather than an app plugin, but everything I’ve read said that should work.
This is being written in python using the Shopify python library, with the sample code as a starting point.
So far the examples for the REST version all work fine, so I assume that OAuth has been handled correctly. Deprecating REST is too bad, since that’s all I really need at this point, but that’s going away.
The problem is the sample GraphQL() call returns a 404, which is odd since the REST calls obviously were able to communicate with the store.
Expected behavior
The sample code should execute an easy GraphQL query:
Actual behavior
urllib.error.HTTPError: HTTP Error 404: Not Found
Steps to reproduce the problem
Run the sample code on a simple shop.
Reduced test case
from shopify import session
session.Session.setup(api_key=API_KEY, secret=API_SECRET)
shop_url = f"{SHOP_NAME}.myshopify.com"
api_version = '2024-07'
state = binascii.b2a_hex(os.urandom(15)).decode("utf-8")
redirect_uri = f"http://{SHOP_NAME}.myshopify.com/admin/api/2025-01/graphql.json"
scopes = ['read_products', 'read_orders']
newSession = session.Session(shop_url, api_version)
auth_url = newSession.create_permission_url(scopes, redirect_uri, state)
access_token = "XXXXXXX"
Can't use sample code "access_token = session.Session.request_token(request_params)"
because request_params aren't defined.
newSession = session.Session(shop_url, api_version, access_token)
shopify.resources.ShopifyResource.activate_session(newSession)
This works fine
order = shopify.resources.Order.find(5925559599255) # Get a specific order
print(f"Order is: {order.attributes}")
This gives an error urllib.error.HTTPError: HTTP Error 404: Not Found in graphql.py on line 32:
shopify.resources.GraphQL().execute("{ shop { name id } }")
Checklist
The text was updated successfully, but these errors were encountered: