I am getting 400 invalid request when trying to retrieve recommendations using the Spotify Web Api with react. I have made it retrieve the song I am playing, so I know the OAuth2 is working correctly.
The function for retrieving the recommendation is:
// Scopes
var scope = 'user-read-private user-read-email user-read-playback-state';
// Function
getRecommendations() {
var data = {
seed_tracks: [
'spotify:track:3YSgPxT1T1HroVJxpN2aye',
'spotify:track:2TxaEF8u2Po2c3RqevD3sd'
],
seed_artists: [
'spotify:artist:1p2z4hiBCkxfWZ6OvyGBSA',
'spotify:artist:5SwsSD9zyWaWeVyK9qIW9l'
],
seed_genres: [
'classical',
'country'
],
};
spotifyWebApi.getRecommendations(data).then((response) => {
this.setState({
nowPlaying: {
test: response.tracks,
}
})
})
}
any idea what I am doing wrong?
I figured it out. The problem was my input 'spotify:artist:1p2z4hiBCkxfWZ6OvyGBSA'
should only be '1p2z4hiBCkxfWZ6OvyGBSA'
instead.