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));
Replies 26 (26)
Manaspaul623
Tourist
5 0 3

Shopify product searching by title is supported with exactly same product title name. Partially title searching is not supported by shopify in recent Rest Admin api version. But it is available in GraphQL api. You can use it.


@maltillo wrote:

Our app is backend. We allow users to apply bulk price updates to their products. They first need to search and filter through to find the products they want to update. Before they could search 'Blue' and the search would bring up all products with 'blue' in the title. Now that doesn't work.

 

We are using REST API.

 


 

maltillo
Shopify Partner
13 0 0

Thanks for your reply.

 

Our app is written in REST API

Does this mean re-writing the entire app in GraphQL api?

Manaspaul623
Tourist
5 0 3

No, not at all. 

You can only do the searching operation with GraphQL whereas other operation in Rest API


@maltillo wrote:

Thanks for your reply.

 

Our app is written in REST API

Does this mean re-writing the entire app in GraphQL api?



.

WOTIO
Shopify Partner
36 0 6

The parsing method Dante provided worked for me. The links are there in the response, but they will not show up in the browser rendered view of the page if you are printing out the response.

WOTIO App: https://apps.shopify.com/automatic-account-invites
Saso-WD
Shopify Partner
14 0 2

Holly cow, spent 2 hours trying to figure this one out, had the same issue O.o

aatmik
New Member
1 0 0

I totally agree with you and feel like throwing the same egg on the person who decided the stupid syntax of using <>'s for the cursor-pagination links.

How immature to complicate things.

First the user will have to parse the link header itself and use explode to get value of the rel parameter and then use the link finally.

MarceloDias
New Member
1 0 0

I was thinking that i had the same problem,

but the truth was, how the link is between "<>" and i tried to see it in a Browser

the Browser understand that everything is between the "<>" as a HTML tag.

But in Google Chrome is possible to use CTRL + U ( or right click -> show source code ) and there will be the link.