How to get the next page by /admin/api/2021-01/products.json

Solved
hiromura
Excursionist
20 1 4

We can get our product information  by '/admin/api/2021-01/products.json?fields=vendor,variants&limit=250'.

But we can get the first page of 250 information of our products only. 

We can not get next page. 

The API's header is as following;  

    [17] => X-Shopify-API-Version: 2021-01

[18] => Link: ; rel="next"

There is no url for the next page.

Please let us know how to get the next page url.

Accepted Solution (1)

Accepted Solutions
awwdam
Shopify Staff
Shopify Staff
241 40 30

This is an accepted solution.

Hey @hiromura

Thanks for getting back to me here. I was able to locate the logs associated the X-Request-ID shared, and can confirm that the pagination info was sent with this response (via the Link header). My suggestion would be to first check if something in your app or tooling could be preventing the full content of the header from coming through on your end.

You can also test a REST request and pagination on a store directly from the admin in browser to confirm functionality. To do this, from the store's admin submit the request via the browser url bar:

eg.  https://{{store}}.myshopify.com/admin/api/2021-01/products.json?fields=vendor,variants&limit=250
 

Using Chrome Developer Tools use Google Chrome Inspect > Network> [select request from list]> Headers (click for link to guide) and monitor for HTTP response and headers.  Hope that offers a few places to start -  Best!

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 6 (6)
awwdam
Shopify Staff
Shopify Staff
241 40 30

Hey @hiromura,

Just wanted to jump in here and take a closer look. We have an overview doc here (examples provided) that covers cursor-based pagination for supported REST endpoints. If a store's entire catalog can be returned in a single request based on limit, this would be expected; eg limit=250 but the product count =200. My team make a few tests using the most recently updated guide as shared and found no issue with pagination. That said, I do have a few questions below, and would be willing to share insights based on a bit more info:

1.   Does this happen across all versions of the API? Have you tested 2021-04, 2021-07 or 2021-10? 
2.  
Can you paginate the 250 products by using a smaller limit? eg. limit=25
3.  Do you have an x-request-id header returned in the response that you would be willing to share? 
4.  What is the timeframe since this unexpected behaviour started? 
OPTIONAL: Do you have more than one shop to test on? 

I'll keep eye out here - 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

hiromura
Excursionist
20 1 4

Thank you very much for your reply.  I answer to you as followings;

1.   Does this happen across all versions of the API? Have you tested 2021-04, 2021-07 or 2021-10? 

Yes, we have tried all. but the response header does not include the next page URL, which we  could  have  been  getting by  the same program by a month ago without problem for a few years.

    [17] => X-Shopify-API-Version: 2021-10

[18] => Link: ; rel="next"

The above is the response header. AS you see there is no next url for the pagenation.

2.  Can you paginate the 250 products by using a smaller limit? eg. limit=25

We tried but the the result was the same, 

[18] => Link: ; rel="next"'   

This header has no next url.


3.  Do you have an x-request-id header returned in the response that you would be willing to share? 

Yes, we can get it as under;

    [27] => X-Request-ID: 4a290a09-******************5a3e59b0


4.  What is the timeframe since this unexpected behaviour started? 

Maybe, it started a month ago,  but that is not sure.

For a few years before this problem happened, we could have successfully got the next pagenation url at the part 'HERE' below;

[18] => Link: {HERE}; rel="next"

The API url we use to get the product infomartion is;

https://{our_shopify_key}/admin/api/2021-10/products.json?fields=vendor,variants&limit=250

By the above we can get only the first 250 products details but with the header without the next pagenation url like as under;

[18] => Link: ; rel="next"

Please give us your comment if you give us your advice.

 

awwdam
Shopify Staff
Shopify Staff
241 40 30

Hey @hiromura thanks for all of the details! I would be happy to take a closer look here, but will need a full x-request-id header to do so, ideally from the most recent request that exhibits this functionality - an x-request-id response header is safe to share in the forums as it has no visible store or app specific info. I will keep an eye out here - Best.

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

hiromura
Excursionist
20 1 4

Thank you for your quick reply.

I will send you the X-Request-ID:

[27] => X-Request-ID: cfc2df3e-ad51-41c7-86c3-0cca74b28cb4

Please let us have your advice.

 

awwdam
Shopify Staff
Shopify Staff
241 40 30

This is an accepted solution.

Hey @hiromura

Thanks for getting back to me here. I was able to locate the logs associated the X-Request-ID shared, and can confirm that the pagination info was sent with this response (via the Link header). My suggestion would be to first check if something in your app or tooling could be preventing the full content of the header from coming through on your end.

You can also test a REST request and pagination on a store directly from the admin in browser to confirm functionality. To do this, from the store's admin submit the request via the browser url bar:

eg.  https://{{store}}.myshopify.com/admin/api/2021-01/products.json?fields=vendor,variants&limit=250
 

Using Chrome Developer Tools use Google Chrome Inspect > Network> [select request from list]> Headers (click for link to guide) and monitor for HTTP response and headers.  Hope that offers a few places to start -  Best!

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

hiromura
Excursionist
20 1 4

Hi awwdam,

Thank you very much for your quick advice. Our problem has been clearly solved. 

We can surely get the next link url in the response header.

As I checked the response header by browser, I could not see the next link because the link is in the html tag.

I am very sorry for your spending time for my carelessness.

Again, thank you very much!