List of returned orders empty when using Python API

Highlighted
Tourist
8 1 11

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!

0 Likes
Highlighted
Shopify Staff
Shopify Staff
587 72 130

Hey @devdude,

 

Are you adding any parameters to your call? If those orders in your test store are archived, your GET to the orders endpoint needs to include the param status=any to have those orders included in the response.

 

If the missing parameter isn't the cause, please send along the X-Request_Id value found in the response headers for the call, and I can use this to investigate further in our logs.

JB | Developer Support @ Shopify
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Click Accept as Solution 

0 Likes
Highlighted
New Member
2 0 0

Hi 

Even I'm facing the same issue with node.js request module, I'm using the request module to make a get request on api using access token, even in postman I'm getting empty array, 

My reqeust Id is :- fa4a889e-4040-47f2-84d0-ca1f684f4177

 

 

My code for accessing shopify api is :

let orderUrl = shopUrl+`/admin/api/${shopifyApiVersion}/orders.json`;
let queryParams = {'selectedView' : 'all'};
let headers = {'X-Shopify-Access-Token': event.requestAttributes.accessToken}
let orderDetails = await request.get(orderUrl, {headers: headers, qs : queryParams});


this is the response I'm getting :

{
'orders' : []
}
0 Likes