Skip to content

REST works, GraphQL returns 404s #760

@czei

Description

@czei

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:

shopify.resources.GraphQL().execute("{ shop { name id } }")

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

  • I have described this issue in a way that is actionable (if possible)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions