mirror of
https://github.com/spotipy-dev/spotipy.git
synced 2026-04-26 16:15:51 +03:00
[GH-ISSUE #716] can't add a track to a playlist error 405 #429
Labels
No labels
api-bug
bug
dependencies
documentation
duplicate
enhancement
external-ide
headless-mode
implicit-grant-flow
invalid
missing-endpoint
pr-welcome
private-api
pull-request
question
spotipy3
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/spotipy#429
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @Yousufakhan95 on GitHub (Aug 13, 2021).
Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/716
ok so I am trying to add a track to my playlist using Spotipy. and I am providing all the right parameters so I don't get what I am doing wrong here and I am getting an error 405 which I don't know how to handle.
so if you take a look at the
add_track_to_given_playlistmethod its supposed to add a track to my playlist but its throwing the following error at me.thanks
@Peter-Schorn commented on GitHub (Aug 13, 2021):
There's a bug with your code that parses the playlist id from the URL. Look very closely at the URL:
Notice it contains a query parameter
siwith a value of99f6cc248a4746a0. This is not part of the id. The id is5x68eFlK6lB8oN7wAcAL1Z.Furthermore, there are issues with your authorization code. It doesn't make sense to re-authorize your app before every request. That's just a waste of time. Get rid of the
get_user_authmethod and change the initializer to the following:Use the
spot_objectinstance attribute for all requests to spotify.@Yousufakhan95 commented on GitHub (Aug 14, 2021):
ok thanks for the advice on the auth and the method. the auth still works and now the code looks better too! but the problem is still here. instead of getting error 405 now I am getting error 400 which is a little better but I can't seem to get the problem here again. here is the revised code with the error message.
and here is the error message. reminder this is for the
add_track_to_given_playlistmethod@Peter-Schorn commented on GitHub (Aug 14, 2021):
The
itemsparameter ofplaylist_add_itemsexpects a list of tracks/episodes, not a single track. You should be able to tell that based on that fact thatitemsis plural. Also, you should read the documentation.@Yousufakhan95 commented on GitHub (Aug 14, 2021):
oh ok thanks. sorry about that. is there a way I can just give it only one song to add. or can I just put one song url in the list and give it that. sorry to bother you this is my first time using an api.
@Peter-Schorn commented on GitHub (Aug 14, 2021):
You can always create a list with a single element.
@Yousufakhan95 commented on GitHub (Aug 14, 2021):
ok just tried that and now error 403 here is what I am passing in.
and here is the error message
which scopes should I use?
@Peter-Schorn commented on GitHub (Aug 14, 2021):
The
positionparameter should be0because the playlist is empty. lists are zero-indexed, which means the index of the first element is zero. Once again, read the documentation.@Yousufakhan95 commented on GitHub (Aug 14, 2021):
omg thanks it works now. sorry that I was bugging you a-lot. thanks so much. this is why I love the programming community guys like you have made it much easier to get into programming. I wish to help people join this community in the future just like you helped me. thanks a lot man