I am unable to get the featured playlists data in dec2w2a1 from spotify API at https://api.spotify.com/v1/browse/featured-playlists as the output of my API call is {‘error’: {‘status’: 404, ‘message’: ‘Not Found’}}
Below is my code snippet
def get_featured_playlists(url: str, access_token: str, offset: int=1, limit: int=20, next: str=“”) → Dict[Any, Any]:
“”"Perform get() request to featured playlists endpoint
Args:
url (str): Base url for the request
access_token (str): Access token
offset (int, optional): Page offset for pagination. Defaults to 0.
limit (int, optional): Number of elements per page. Defaults to 20.
next (str, optional): Next URL to perform next request. Defaults to "".
Returns:
Dict[Any, Any]: Request response
"""
if next == "":
request_url = f"{url}?offset={offset}&limit={limit}"
else:
request_url = f"{next}"
### START CODE HERE ### (~ 4 lines of code)
# Call get_auth_header() function and pass the access token.
headers = get_auth_header(access_token=access_token)
try:
# Perform a get() request using the request_url and headers.
response = requests.get(url=request_url, headers=headers)
# Use json() method over the response to return it as Python dictionary.
return response.json()
### END CODE HERE ###
except Exception as err:
print(f"Error requesting data: {err}")
return {'error': err}
URL_FEATURE_PLAYLISTS = “https://api.spotify.com/v1/browse/featured-playlists”
Note: the access_token
value from the dictionary token
can be retrieved either using get()
method or dictionary syntax token['access_token']
playlists_response = get_featured_playlists(url=URL_FEATURE_PLAYLISTS, access_token=token.get(‘access_token’))
playlists_response
Output if above code is:
{‘error’: {‘status’: 404, ‘message’: ‘Not Found’}}
I have also checked the spotify documentation which is also saying that getting featured playlists is deprecated.
In this way, I am unable to complete my whole lab as all other exercises also builds upon the exercise 1.
Kindly someone look into it and guide me accordingly…Also anyone other facing that ?? how you guys are rectifying it??