NOTE: I have detailed this in a stackoverflow post as well if you would like some internet points: https://stackoverflow.com/questions/62135563/shopify-api-returns-nothing-when-there-really-is-data
Using the Python shopify API, I create a session and try to fetch all orders for a store. The code looks like this:
import shopify
import pprint
import logging
logger=logging.getLogger(__name__)
shopify.Session.setup(api_key=api_key, secret=api_secret)
session = shopify.Session( myshopify_domain, api_version, access_token)
shopify.ShopifyResource.activate_session(session)
for order in shopify.Order.find():
logger.info(pprint.pformat(order.to_dict()))
So shopify API clearly manages to create and use the session to fetch data successfully, as can be gandered from the log output:
2020-06-01 15:08:47 INFO (MainThread) [pyactiveresource.connection:257::_open()] - GET https://my-store.myshopify.com/admin/api/2020-01/orders.json
2020-06-01 15:08:47 INFO (MainThread) [pyactiveresource.connection:301::_open()] - --> 200 OK 13b
However, the returned list of orders is empty (as is also evident by the “13b” in the log).
But when I look in the shopify admin panel for this development store, I have several orders of varying states and with varying data. There should be at least 4 of them submitted within the last week.
And if I just open the URL mentioned in the log https://my-store.myshopify.com/admin/api/2020-01/orders.json (not the real URL) directly in the browser, I also see a bunch of data there.
To me this raises a few questions:
- How come no orders are returned when using the api, even though it seemingly authenticates fine?
- How could I possibly get data when opening the URL in the browser since I have no authentication set up there?
Any hints are welcome. Thanks!