Solved

Paginated results

manou_mhd
Tourist
4 0 1

I'm currently using the Shopify API to retrieve all the customers, products and orders. The problem is while testing the API in Postman, The API returns the "link" in the header containing the next page token, but from the thrid page I receive the same token. And I'm currently sending the request parameters only one time (in the first call).
I've tried using both 2022-01 and 2021-10 API version. Could you help please ? Thanks!

Accepted Solution (1)
awwdam
Shopify Staff
249 42 36

This is an accepted solution.

Hey @manou_mhd,

After a few requests to my test environment and emulating similar filters to those you used, I was able to paginate through several pages with everything working as expected per our documentation. 

You mentioned that you aren't including a limit parameter in the first request, which might be good preliminary troubleshooting. In the case that a larger volume of data is expected, starting with a count on the resource (orders) should give an idea of how many pages of orders need to be paginated through.

Shopify REST Pagination uses the link header returned, appending page_info=[VALUE]  and limit={<250} parameters. This allows navigation through the resource until there is no longer data to return, at which point a link to the previous page will be returned with the final page.

EG. first request /admin/api/2021-10/orders.json?{filters}&status=any?limit={<250}, second request /admin/api/2021-10/orders.json?page_info={VALUE}&limit={<250}, etc.

Locating request logs for the example IDs shared, I noticed that none of the endpoint URLs include a cursor? Based on this and info above, taking a look back through the documentation should help clarify formatting and process.

If you still feel something isn't working, share any additional example URLs and we can have a look again to provide next steps. 

Cheers! 

awwdam | API 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

View solution in original post

Replies 5 (5)

awwdam
Shopify Staff
249 42 36

Hey @manou_mhd,

Would you be able to provide me with an example of one of the requests that you are making (request body), as well as an x-request-id header value that was returned with the response. I also wanted to ask if you are using our REST pagination docs, if not I would suggest taking a look through to confirm functionality.

I would be happy to take a closer look and pass back any insights from there - Cheers!

awwdam | API 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

manou_mhd
Tourist
4 0 1

Hello @awwdam ,
Thank you for answering me! 

I've checked the documentation of REST pagination, and I'm only sending the parameter updated_at_min="2022-01-01" in the first call without sending page_info, then I'm only sending page_info and limit in the request header.

Here's the X-Request-ID sent in my first request : c6008be9-5f06-4e59-8a63-dc0de735b8e8
Here's the one which returns the same Link in the response header : 649651d4-73d8-443d-a7fd-cd0bb083e143


awwdam
Shopify Staff
249 42 36

This is an accepted solution.

Hey @manou_mhd,

After a few requests to my test environment and emulating similar filters to those you used, I was able to paginate through several pages with everything working as expected per our documentation. 

You mentioned that you aren't including a limit parameter in the first request, which might be good preliminary troubleshooting. In the case that a larger volume of data is expected, starting with a count on the resource (orders) should give an idea of how many pages of orders need to be paginated through.

Shopify REST Pagination uses the link header returned, appending page_info=[VALUE]  and limit={<250} parameters. This allows navigation through the resource until there is no longer data to return, at which point a link to the previous page will be returned with the final page.

EG. first request /admin/api/2021-10/orders.json?{filters}&status=any?limit={<250}, second request /admin/api/2021-10/orders.json?page_info={VALUE}&limit={<250}, etc.

Locating request logs for the example IDs shared, I noticed that none of the endpoint URLs include a cursor? Based on this and info above, taking a look back through the documentation should help clarify formatting and process.

If you still feel something isn't working, share any additional example URLs and we can have a look again to provide next steps. 

Cheers! 

awwdam | API 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

manou_mhd
Tourist
4 0 1

Hello again @awwdam ,

Thank you very much problem solved, I was sending the page_info in the request header instead of the body request. It's working now! 

Thank you !

yessiuk
Visitor
1 0 0

Hey, 

 

I'm stuck in a similar situation here @manou_mhd , do you mind sharing you code within Qlik Sense data load you used to retieve all orders within the loop?

Thanks
Simon