[GH-ISSUE #859] How to deal with HTTP Status 400, Code: -1 when searching for songs? #530

Closed
opened 2026-02-27 23:23:10 +03:00 by kerem · 2 comments
Owner

Originally created by @chaitanya-gvs on GitHub (Sep 24, 2022).
Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/859

So I recently started using Spotify's API through Spotipy library in Python for a school project.

I am getting a Spotify Exception with HTTP Status: 400, Code: -1, for the following line of code,

sp.search(q="track: A Rockin' Good Way (To Mess Around and Fall in Love) artist: Dinah Washington & Brook Benton year: 1960",type='track')

Here, sp is the Spotify client.

I assumed this had something to do with the string quotes or the ampersand (&) but it doesn't seem to be the case because I have tried all possible combinations.

I would like to know how to deal with this.

Thank you.
Screenshot 2022-09-24 051836

Originally created by @chaitanya-gvs on GitHub (Sep 24, 2022). Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/859 So I recently started using Spotify's API through Spotipy library in Python for a school project. I am getting a Spotify Exception with HTTP Status: 400, Code: -1, for the following line of code, ` sp.search(q="track: A Rockin' Good Way (To Mess Around and Fall in Love) artist: Dinah Washington & Brook Benton year: 1960",type='track') ` Here, sp is the Spotify client. I assumed this had something to do with the string quotes or the ampersand (&) but it doesn't seem to be the case because I have tried all possible combinations. I would like to know how to deal with this. Thank you. ![Screenshot 2022-09-24 051836](https://user-images.githubusercontent.com/51097058/192116070-60c1ce69-749a-490d-8695-7c60924f647d.jpg)
kerem 2026-02-27 23:23:10 +03:00
  • closed this issue
  • added the
    question
    label
Author
Owner

@Peter-Schorn commented on GitHub (Oct 5, 2022):

See #845. Also, there shouldn't be spaces after track:, artist:, or year:.

<!-- gh-comment-id:1268731135 --> @Peter-Schorn commented on GitHub (Oct 5, 2022): See #845. Also, there shouldn't be spaces after `track:`, `artist:`, or `year:`.
Author
Owner

@stephanebruckert commented on GitHub (Oct 29, 2022):

Your query (q=) should look like:

query = 'track:"{0}"+artist:"{1}"'.format(track_name, artist)

or with year:

query = 'track:"{0}"+artist:"{1}"+year:"{2}"'.format(track_name, artist, year)

but as per the link shared by @Peter-Schorn, that whole query string must be < 100 characters. Depending on your use case you might want to ignore or trim some track names. If you have more question about that let's continue on https://github.com/plamere/spotipy/issues/845

<!-- gh-comment-id:1295820952 --> @stephanebruckert commented on GitHub (Oct 29, 2022): Your query (`q=`) should look like: query = 'track:"{0}"+artist:"{1}"'.format(track_name, artist) or with `year`: query = 'track:"{0}"+artist:"{1}"+year:"{2}"'.format(track_name, artist, year) but as per the link shared by @Peter-Schorn, that whole `query` string must be < 100 characters. Depending on your use case you might want to ignore or trim some track names. If you have more question about that let's continue on https://github.com/plamere/spotipy/issues/845
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/spotipy#530
No description provided.