Announcements

Help Wizard

Step 1

NEXT STEP

resolve

resolve

headers = {
"Authorization" : "application/json"
}
endpoint = "https://api.spotify.com/v1/search"
data = urlencode({"type":"album","include_external":"audio"})
print(data),
lookup_url = f"{endpoint}?{data}"
print(lookup_url)
r= requests.get(lookup_url, data=data, headers = headers)#running print(r.status_code)

 

I am getting error as 

type=album&include_external=audio
https://api.spotify.com/v1/search?type=album&include_external=audio
400

can anyone e=help me resolve it
Reply
1 Reply

You get this error, because you don't provide a search query (q in my example code).

Also, you don't provide an Bearer Access Token after Authorization.

You can get an Access Token with the Client Credentials Flow or the Authorization Code Flow.

 

My example code:

 

import requests

headers = {

    'Accept': 'application/json',

    'Content-Type': 'application/json',

    'Authorization': 'Bearer YourAccessCodeHere',

}

params = {

    'q': 'Queen',

    'type': 'album',

    'include_external': 'audio',

}

r = requests.get('https://api.spotify.com/v1/search ', params=params, headers=headers)

XimzendSpotify Star
Help others find this answer and click "Accept as Solution".
If you appreciate my answer, maybe give me a Like.
Note: I'm not a Spotify employee.

Suggested posts

Let's introduce ourselves!

Hey there you,   Yeah, you! 😁   Welcome - we're glad you joined the Spotify Community!   While you here, let's have a fun game and get…

ModeratorStaff / Moderator/ 4 years ago  in Social & Random