C2W2 Graded Assignment Error 404 when running exercises 4 and 5

Hi everyone,

I am trying to debug the exercises 4 and 5. Exercise 4 managed to run smoothly with the response_status code of 200.

Requesting to: https://api.spotify.com/v1/browse/new-releases?offset=20&limit=20
200
Requesting to: https://api.spotify.com/v1/browse/new-releases?offset=40&limit=20
200
Requesting to: https://api.spotify.com/v1/browse/new-releases?offset=60&limit=20
200
Requesting to: https://api.spotify.com/v1/browse/new-releases?offset=80&limit=20
200

However, the Exercise 5 returned a status_code of 404 instead.

Getting information about each album
Requesting to: https://api.spotify.com/v1/browse/new-releases/1Mo4aZ8pdj6L1jx8zSwJnt/tracks
response <Response [404]>
404
Error occurred during request: Expecting value: line 1 column 1 (char 0)
Album 1Mo4aZ8pdj6L1jx8zSwJnt has been processed successfully
Requesting to: https://api.spotify.com/v1/browse/new-releases/7MNrrItJpom6uMJWdT0XD8/tracks
response <Response [404]>
404
Error occurred during request: Expecting value: line 1 column 1 (char 0)
Album 7MNrrItJpom6uMJWdT0XD8 has been processed successfully
Requesting to: https://api.spotify.com/v1/browse/new-releases/4YQ8O3PQb7cZnnLeqNPaa1/tracks
response <Response [404]>
404
Error occurred during request: Expecting value: line 1 column 1 (char 0)
Album 4YQ8O3PQb7cZnnLeqNPaa1 has been processed successfully
Requesting to: https://api.spotify.com/v1/browse/new-releases/4MGpOqMU3FlZ7li35laoBu/tracks
response <Response [404]>
404

From my understanding, Spotify changed their apis line-up as of 27 November 2024 with this link

How do I debug the code then for this lab assignment? Thanks!

My lab code is bfgqrlpvkggc.

Hello @Loo_Guan_Yee,

Yes you are correct, I was getting a similar error changed the end of the while loop in Exercise 5:

# Extend the album_data list with the value from "items" in response_json.
album_data.album_data(album_data["album_data"])
# Update request_url with the "next" value from response_json.
request_url = album_data["album_data"]

to this to make it work:

# Extend the album_data list with the value from "items" in response_json.
album_data.extend(response_json.get("items", []))
# Update request_url with the "next" value from response_json.
request_url = response_json.get("next")

Correct output:

Hi @Georgios ,

Upon close inspection on the url link from your shell output, I realised the bug originated from the exercise 6 located in the main.py file. I typed in URL_NEW_RELEASES instead ofURL_ALBUM_TRACKS.

Btw, both of your code mentioned can work. Thanks!

1 Like