Announcements

"Save Albums for Current User" endpoint returns a different response code than the documents.

Solved!
Reply

"Save Albums for Current User" endpoint returns a different response code than the documents.

Visitor

Plan

Premium

Country

Turkey

Platform

Spotify API with Python 

Operating System

Windows 10 

 

My Question or Issue

https://developer.spotify.com/documentation/web-api/reference/library/save-albums-user/

Looking at this document, if the process is successful, the result is stated to be 201. But when I run my own code, the result is 200, and the process seems to have finished successfully.

My Code: 

 

   def save_album_user(self, albums_ids):
        params = {"ids": albums_ids}
        save_album_for_user_response = requests.put(f"{self.BASE_API_URL}/me/albums", params=params, headers=
        {"Authorization": f"{self.data_list[1]} {self.data_list[0]}", "Content-Type": "application/json"})
        print(f"HTTP STATUS CODE: {save_album_for_user_response.status_code}")
        print(f"HTTP HEADERS: {save_album_for_user_response.headers}")
        if save_album_for_user_response.status_code == 200:
            return True
        else:
            return save_album_for_user_response.json()

 

Code Result 

 

HTTP STATUS CODE: 200
HTTP HEADERS: {'content-type': 'text/plain; charset=utf-8', 'cache-control': 'private, max-age=0', 'x-robots-tag': 'noindex, nofollow', 'access-control-allow-origin': '*', 'access-control-allow-headers': 'Accept, App-Platform, Authorization, Content-Type, Origin, Retry-After, Spotify-App-Version, X-Cloud-Trace-Context', 'access-control-allow-methods': 'GET, POST, OPTIONS, PUT, DELETE, PATCH', 'access-control-allow-credentials': 'true', 'access-control-max-age': '604800', 'Content-Length': '0', 'strict-transport-security': 'max-age=31536000', 'x-content-type-options': 'nosniff', 'date': 'Tue, 28 Jul 2020 15:57:36 GMT', 'server': 'envoy', 'Via': 'HTTP/2 edgeproxy, 1.1 google', 'Alt-Svc': 'clear'}
True

 

I'm a little confused. Is my code wrong or the document is wrong?

image.png
1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Solution!

Re: "Save Albums for Current User" endpoint returns a different response code than the doc

Spotify
Spotify

Thank you for reporting this, @mehmetkiran! This seems to be a mistake in our documentation. We'll look at fixing it in our next round of updates.

View solution in original post

1 Reply
Highlighted
Solution!

Re: "Save Albums for Current User" endpoint returns a different response code than the doc

Spotify
Spotify

Thank you for reporting this, @mehmetkiran! This seems to be a mistake in our documentation. We'll look at fixing it in our next round of updates.

View solution in original post

SUGGESTED POSTS