Problems using Spotify Node

Cannot add tracks to a playlist.

I always got the following error, only first track is added:

There was a problem executing the workflow:
“Cannot read properties of undefined (reading ‘replace’)”

Problem executing workflow

There was a problem executing the workflow:
“Cannot read properties of undefined (reading ‘replace’)”

Share the output returned by the last node

Information on your n8n setup

  • n8n version: 1.6.0.
  • Database you’re using (default: SQLite):
  • Running n8n with the execution process [own(default), main]:
  • Running n8n via [Docker, npm, n8n.cloud, desktop app]: Mac Desktop App

Hi @Nelson_Paz_y_Mino, welcome to the community :tada:

I am sorry to hear you’re having trouble. I tried executing your workflow and it seems fine for the most port:

The error I am getting on the final Spotify node suggests I don’t have permissions to write to your playlist which seems to be expected:

Can you confirm if this is the node you’re also getting your error on? If so, I suspect the error could be caused by your expression {{$node["Parameters"].json["nullPlaylist"]}} used in the Playlist ID field. For the first incoming item, it would try to read the first item of your Parameters node which works fine. However, for the second incoming item it would try to read the second item of your Parameters node which doesn’t exist.

You can avoid this by using an expression like {{ $item(0).$node["Parameters"].json["nullPlaylist"] }} instead. By adding $item(0)., the expression will always use the first item of the Parameters node (this is explained here in more detail).

Hope this helps!

1 Like

It worked! The problem was in the last node. I changed the expression to:

{{$item(0).$node[“FunctionItem”].json[“0”][“json”][“nullPlaylist”]}}

Thanks a lot for your time.

1 Like