Help with cursor based paging

Solved
tbirnseth
Shopify Partner
9 0 12

I'm trying to use the newer cursor based paging.  I use a url similar to:

store/admin/api/2019-07/products.json?limit=5

The headers returned with after the call to the api have:

x-shopify-shop-api-call-limit: 1/40
x-shopify-api-version: 2019-07
link: ; rel="next"

There is no 'page_info' parameter for me to use to get the next page of results.  And how do I use a 'rel' attribute in an API call?  Is this passed as a 'rel' header?

Be really helpful if someone could post a code segment of looping through some pages.  The docs don't make a lot of sense to me since the response headers in the docs don't match the response headers from the api.

I'd think it would be something like:

$link_info='';
do {
  $new_data = Http:get("shop/admin/api/2019-07/products.json?limit=5".($link_info?"&page_info=$link_info":'') );
  $link_header = getLinkHeader();
  $link_info= $link_header;  // should contain something like page_info=xyz&rel=next
  if( $new_data )
    processNewData($new_data);
} while(!empty($new_data));
Accepted Solution (1)
Josh
Shopify Staff
Shopify Staff
1134 84 233

This is an accepted solution.

Hello again @tbirnseth , 

 

Have you attempted any other method of sending these calls to eliminate potential causes yet? If this happens with a cURL request too it would be good information to have since it would point to a shop issue which is yet to come up. If that were the case I could set up a private app on whatever shop you're using to see if I can replicate the same result.

 

For example, this cURL should work if you swap in your own private app API credentials and shop URL, provided that you're using a private app that is. 

 

curl -I -X GET https://{private_app_api_key}:{private_app_password}@{shop_url}.myshopify.com/admin/api/2019-10/orders.json?limit=1 -H 'Content-Type: application/json'

If your app uses OAuth and has an access token instead, you can send the cURL to your shop URL with your access token as a header : 

 

curl -I -X GET https://{shop-url}.myshopify.com/admin/api/2019-10/orders.json?limit=1 -H "Content-Type: application/json" -H "X-Shopify-Access-Token: {app_access_token}"

If the link header is still missing after trying one of the above requests and you could post the result of the cURL here, it would help a lot. 

Josh | 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 the Shopify Help Center or the Shopify Blog

View solution in original post

Replies 26 (26)