Error 413 on spotify

Hello,
I try to put all my “like” Spotify on 4 playlist (by popularity)

But, i have 6859 track like, and, the “SET” nodes, not support that (erreur 413)

Is there a way to process in batches of 1000 bit by bit?

Thx

Hi @YDeltagon, welcome to the community!

Are you by any chance using a n8n version before 0.160.0? This version introduces a bug fix by @Jon fixing the Spotify node behavior for more than 1,000 results.

Or is the error thrown by the Set node? That would be most unusual and definitely unexpected to me. Could you share your workflow?

I just updated today.
Because before, I only receive 1000 likes

Now I have my 68xx fine
But, I cannot process so much data on the following nodes (error 413)

Thanks! Could you share your workflow’s JSON (you can simply select your nodes and press Ctrl+C to copy it) and a screenshot of the error you are getting?

LIKE

ID & TOP

Thanks a lot! So the 413 error is thrown when a webserver can’t handle the data amount.

Unfortunately I am not entirely sure if there are ways of adjusting the respective settings for the desktop app (but maybe @ivov can confirm this).

What you could try in the meantime is building your workflow with less data (e.g. by fetching the tracks from a relatively small playlist) until it works. Once finished building your workflow, run it in the background (for example triggered by the Cron node after activating your workflow). That way, execution data wouldn’t need to be exchanged between frontend and backend as the workflow executes, possibly avoiding the 413 error.

it seems strange to me that it goes through the web, since it is the “set” nodes which seems to be causing problems (which is therefore theoretically local)

With 1000 music, it goes without problems

There is no way to process 1000 by 1000?

Google trad quality :3

The problem here wouldn’t be the set node but the overall amount of data exchanged between the front- and the backend. The limit is just reached when the Set node is about to be executed. It’s likely you encounter similar problems with other nodes too.

Processing only a limited number of records at a time would also solve the problem, but the Spotify node does not offer an offset option at the moment unfortunately (so it can only give you the first n tracks, but not the next batch after that). You might be able to use the HTTP Request node for this, but I haven’t used the Spotify API so far so can’t provide an example I am afraid.

Yes, I have the problem with other nodes
You should be able to choose directly in the spotify nodes, which data to retrieve

Allowing users to specify the offset would be a great feature request, might be worth posting it in a separate topic as such.

But for a quick resolution I’d suggest trying the aforementioned approach of having your workflow run in the background instead of executing it manually and have it run on the canvas.

I have already used the Python version of the API https://spotipy.readthedocs.io/
It allows precisely to re-send a request from a number previously

Like, I get 1000 back from
And after, I get 1000 from 1000
And after 1000 from 2000…

limit_liked_track = 1000
offset_liked_track = 0

API Spotify offset : Web API Reference | Spotify for Developers

As said, this would be a great feature request, but is nothing the node currently offer I am afraid.

OK, I need to learn how to use APIs with N8N
Tutorials? :3

Hey, so I had a first look into this and Spotify seems to be fairly API friendly.

Here’s a quick example workflow, fetching 25 tracks using an offset value and the Set node afterwards to keep only artist and track name:

Example Workflow

The endpoint used is documented by Spotify here: Web API Reference | Spotify for Developers

You can see how I simply copied the method (GET) and URL (https://api.spotify.com/v1/me/tracks) in the respective fields of the HTTP Request node and added query parameters for limit and offset.

The authentication is relatively simple as well, these are the values I’ve used for my OAuth2 credentials (you’d simply need to set your own client ID and client secret):

Work great
But
How to go from a JSON to a real readable list?


EDIT : THIS STUPID : {

      "parameters": {
        "fieldToSplitOut": "items",
        "options": {}
      },
      "name": "Item Lists",
      "type": "n8n-nodes-base.itemLists",
      "typeVersion": 1,
      "position": [
        680,
        300
      ]
    },

Memo to myself, read everything before posting!

1 Like

Glad to see you have it working :+1:

Ok, new problem I can’t make a loop, the goal being to vary the offset at each loop until the offset is equal to or greater than the total number of tracks

Hi @YDeltagon, you might want to have a look at this similar thread:

It’s not Spotify-specific, but describes a possible approach to reducing the amount of data processed during an execution.

I found :

Work perfectly

1 Like