Hi everyone,
As part of a personal project, I've created a small NodeJS program that automatically creates Spotify playlists from the latest setlists of my favourite bands. I've spotted a few small problems with searching for certain songs from the Spotify API. Here is an example:
const spotifyApi = new SpotifyWebApi({
clientId: process.env.SPOTIFY_CLIENT_ID,
clientSecret: process.env.SPOTIFY_CLIENT_SECRET
});
const data = await spotifyApi.clientCredentialsGrant();
spotifyApi.setAccessToken(data.body['access_token']);
const search = await spotifyApi.searchTracks("track:You're Crazy artist:Guns N' Roses", { limit: 1 });
console.log("Result: ", search.body.tracks.items);
In this example, I use the spotify-web-api-node library and the Client Credentials flow to search for titles corresponding to the song "You're Crazy", by the artist "Guns N' Roses". This request doesn't return anything, as if the song was not found on Spotify.
At first I thought the problem came from the NodeJS library, especially around the parameters (escaping apostrophes, etc), but apparently not. I've tried playing around a bit with the "try it" console available on the official Spotify API documentation, and this request doesn't return anything either:
curl -X "GET" "https://api.spotify.com/v1/search?q=track%3AYou're%20Crazy%20artist%3AGuns%20N'%20Roses&type=track" -H "Accept: application/json" -H "Content-Type: application/json" -H "Authorization: Bearer _____"
I thought the formatting of my request was bad but it works with "Knockin' On Heaven's Door":
curl -X "GET" "https://api.spotify.com/v1/search?q=track%3AKnockin'%20On%20Heaven's%20Door%20artist%3AGuns%20N'%20Roses&type=track" -H "Accept: application/json" -H "Content-Type: application/json" -H "Authorization: Bearer _____"
Could someone help me? Is my request badly formatted?