HTTP Pagination not working with Amazon SP-API

Describe the problem/error/question

I am trying to fetch Amazon SKU off my seller account, AMAZON SP-API CATALOG PAGINATION using the documentation, and also taking idea from this stack overflow Solution however the workflow keeps looping till infinite until I deliberately stop it, and still I get no output, I have attached my workflow below, also we will not get the “nextToken” until the request is fetch once, without “nextToken” we can’t pass to “PageToken”

What is the error message (if any)?

Please share your workflow

Share the output returned by the last node

Information on your n8n setup

  • n8n version: 2.1.4
  • Database (default: SQLite): SQLite
  • Running n8n via (Docker, npm, n8n cloud, desktop app): Docker
  • Operating system: Proxmox LXC

Hi @Mohit_Chauhan, welcome!

Your current approach looks like you’re manually getting a token and then “Fetch Listings”, which won’t work as you expect,

I think you first need to set up Authentication, probably using OAuth 2,

After that, you can use the “Fetch Listings” node as intended with just a single node and pagination if the endpoint supports it..

Hello @mohamed3nan, Thankyou,

However As far as I know, In Amazon SP-API we first need to initialize LWA TOKEN, and with that token we can do and perform anything, also as far as I know amazon don’t give OAuth2 2,

Kindly confirm if I’m wrong

The parameters and URL endpoint in your “Get LWA Token” node look like they are for OAuth 2, I’m not sure though,

For now, if you don’t want to try that approach: if you are successfully getting a token but then receive no output from the “Fetch Listings” node, then something is wrong with your configuration..

If you can attach a screenshot showing what you’re getting, that would be helpful,

I also noticed this referencing:

Try this instead:

Once you get the output, setting up pagination will be easy..

1 Like

Without Enabling Pagination I am able to get output but till 1st page only but after enabling Pagination its keeps looping

Okay,

hmm the loop is probably happening because “Status Code(s) when Complete” expects a status code, but you’re passing an expression instead:

Try changing it to “Other”:

Then write a suitable expression like:

{{!$response.body.pagination.nextToken}}

or

{{$response.body.pagination.nextToken == undefined}}

I’m just guessing since I can’t see the output, but hope this helps!

Thank you so much, it worked

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.