Error with 2021-01 API and using pagination to get ALL orders

JashanKhela
New Member
6 0 0

We are trying to get all of our order information from our Shopify store. We are trying to use the new API (2021-01) and the cursor-based pagination to sync all of those orders to our own MySQL database. 

We have tried using the new API to get orders like this 

 

GET /admin/api/2021-01/orders.json
Copy

 

  But we want to get all of our orders whether they are open, closed, canceled, etc by default it is only giving us the orders with the status =  open -- so we passed it any parameter like below

 

GET /admin/api/2021-01/orders.json?status=any
Copy

 

Finally, we wanted to use cursor-based pagination to get ALL orders

 

/admin/api/2021-01/orders.json?page_info=eyJzdGF0dXMiOiJhbnkiLCJsYXN0X2lkIjozMjA0MDMxMTg1MDY5LCJsYXN0X3ZhbHVlIjoiMjAyMS0wMS0yNiAxNjozODoxMS42MTI2NzQiLCJkaXJlY3Rpb24iOiJuZXh0In0&status=any
Copy

 

 

and finally, we wanted to use the cursor-based pagination to continue getting our orders until there are no more. So we used the API call and when we did this we got the response of "resulted in a `400 Bad Request` response:\n

   {"errors":{"status":"status cannot be passed when page_info is present. See https:\/\/help.shopify.com\/api\/guides\/pag (truncated...)\n" 

 

 

 

What Am I Doing Wrong? I just want to use the cursor-based pagination to pull ALL my orders? Please help?

0 Likes
_JB
Shopify Staff
Shopify Staff
750 86 164

Hey @JashanKhela,

Once you make the initial call using the ?status=any parameter, that parameter doesn't need to be added to subsequent calls. So for the second call just use:

 

/admin/api/2021-01/orders.json?page_info=eyJzdGF0dXMiOiJhbnkiLCJsYXN0X2lkIjozMjA0MDMxMTg1MDY5LCJsYXN0X3ZhbHVlIjoiMjAyMS0wMS0yNiAxNjozODoxMS42MTI2NzQiLCJkaXJlY3Rpb24iOiJuZXh0In0

 

JB | Developer Support @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

0 Likes
JashanKhela
New Member
6 0 0

I thought we cannot pass the page info parameter in the API call anymore?

0 Likes
_JB
Shopify Staff
Shopify Staff
750 86 164

Hey @JashanKhela,

You might be referring to the page parameter. You're correct that page can no longer be passed. However page_info is the new parameter to use which replaces page. This parameter is made available in the response header of any call that requires pagination, all you have to do it make another request to the provided URL containing the page_info param, and that will give you the next page of results based on params present in the first call. 

Be sure to check out our pagination guides for both REST and GraphQL, each guide contains a step by step example.

JB | Developer Support @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

0 Likes