Search code examples
postgetspotify

"service not found" spotify api call "get"


Am doing my first API call via cmd on windows. Trying to access artist API on Spotify. I used following--

POST:

curl -X POST "https://accounts.spotify.com/api/token" -H "Content-Type: application/x-www-form-urlencoded" -d "grant_type=client_credentials&client_id=xyz_id&client_secret=xyz_secret"

GET:

curl --request GET "https://api.spotify.com/v1/album/0t7EBnbzVx0Ekhi6PHsyrh?si=JqtWdetqRv-_4aHRhVB0UQ" --header "Authorization: Bearer BQCp72s8....w9w"

I don't know why isn't it able to find service and how to fix it. The response says the service isn't found.

response I got:

{
  "error": {
    "status": 404,
    "message": "Service not found"
  }
}

Am expecting response something like this-->

{
  "external_urls": {
    "spotify": "https://open.spotify.com/artist/4Z8W4fKeB5YxbusRsdQVPb"
  },
  "followers": {
    "href": null,
    "total": 7625607
  },
  "genres": [
    "alternative rock",
    "art rock",
    "melancholia",
    "oxford indie",
    "permanent wave",
    "rock"
  ],
  "href": "https://api.spotify.com/v1/artists/4Z8W4fKeB5YxbusRsdQVPb",
  "id": "4Z8W4fKeB5YxbusRsdQVPb",
  "images": [
    {
      "height": 640,
      "url": "https://i.scdn.co/image/ab6761610000e5eba03696716c9ee605006047fd",
      "width": 640
    },
    {
      "height": 320,
      "url": "https://i.scdn.co/image/ab67616100005174a03696716c9ee605006047fd",
      "width": 320
    },
    {
      "height": 160,
      "url": "https://i.scdn.co/image/ab6761610000f178a03696716c9ee605006047fd",
      "width": 160
    }
  ],
  "name": "Radiohead",
  "popularity": 79,
  "type": "artist",
  "uri": "spotify:artist:4Z8W4fKeB5YxbusRsdQVPb"
}

I searched but just didn't get the right answer anywhere. Someone had the same problem and later got to know that their:

"access token that can't read the user's resources".

But I don't know what it means and how to fix it. Can anybody explain, and tell how can I solve this problem?


Solution

  • The endpoint for getting an Album is as follows:

    https://api.spotify.com/v1/albums/{id}
    

    Note the "s" in Albums with this included hopefully will get the correct response, so can try something like as follows

    curl --request GET "https://api.spotify.com/v1/albums/0t7EBnbzVx0Ekhi6PHsyrh?si=JqtWdetqRv-_4aHRhVB0UQ" --header "Authorization: Bearer BQCp72s8....w9w"
    

    Web API Reference - Get Album