Re: How to make paginated requests to the REST Admin API using App Bridge Authenticated Fetch?

Solved

How to make paginated requests to the REST Admin API using App Bridge Authenticated Fetch?

mattdlockyer
Tourist
5 0 1

How do I make paginated requests using App Bridge authenticated fetch to the REST Admin API? I'm not seeing it anywhere in the documentation and the app-bridge github repo is 404.

Initial authenticated fetch request:
https://888f7c2e6c60.ngrok.io/rest/v1/?path=products/count&shop=lachlantest2.myshopify.com
- returns /admin/api/2022-01/products.json

I attempt to add a query param using the page_info from the initial response:
https://888f7c2e6c60.ngrok.io/rest/v1/?path=products&page_info=eyJsYXN0X2lkIjo3NjMzMTY3MDU3MTI1LCJsY...
- returns the same response as the initial /admin/api/2022-01/products.json

More generally, how to you pass query params (e.g., limit=250) to authenticated fetch URI?
Is the pagination failing because of https://shopify.dev/api/usage/pagination-rest#parameters?

Accepted Solution (1)

JoeyF
Shopify Staff (Retired)
35 7 12

This is an accepted solution.

When your server receives the (second) request, does it receive the page_info parameter?

 

If you're not sure, can you please paste your server code (that handles requests to /rest/v1)?

To learn more visit the Shopify Help Center or the Community Blog.

View solution in original post

Replies 4 (4)

JoeyF
Shopify Staff (Retired)
35 7 12

This is an accepted solution.

When your server receives the (second) request, does it receive the page_info parameter?

 

If you're not sure, can you please paste your server code (that handles requests to /rest/v1)?

To learn more visit the Shopify Help Center or the Community Blog.

mattdlockyer
Tourist
5 0 1

Hi, yes it does. but it is the same page_info value as the initial request, as is the body. 

page_info=eyJsYXN0X2lkIjo3NjMzMTY3MDU3MTI1LCJsYXN0X3ZhbHVlIjoiYmxhaDE1IiwiZGlyZWN0aW9uIjoibmV4dCJ9

that is the value that is being passed in as the query a param. I've attached a photo as well.pagination via authenticated fetchpagination via authenticated fetch

JoeyF
Shopify Staff (Retired)
35 7 12

Let try to isolate the problem ...

 

If you don't use App Bridge and authenticated-fetch, are you able to make paginated requests from your server successfully?

To learn more visit the Shopify Help Center or the Community Blog.

mattdlockyer
Tourist
5 0 1

Your suggestion helped uncover the issue.  The server was extracting the params correctly from the authenticated fetch URI, but was not setting those entries correctly in the Admin API's request.query object.   

Thanks very much for your help!