Peter-Schorn / SpotifyAPI

A Swift library for the Spotify web API. Supports all endpoints.
https://peter-schorn.github.io/SpotifyAPI/documentation/spotifywebapi
MIT License
269 stars 33 forks source link

Spotify API has changed how IDs are specified in body for PUT/DELETE methods #66

Open danwood opened 6 days ago

danwood commented 6 days ago

Not sure when this changed, but the current (3.0.3) implementation of saveItemsForCurrentUser and removeItemsForCurrentUser when idsInBody is true doesn't work with Spotify API any more. It used to be that we could pass in the array of IDs in the request body, but now it has to be serialized as JSON with the "ids" key. Otherwise you get a 400 error complaining about the missing ids parameter.

Quickly hacking at my local files, I found that if we pass in ["ids" : ids] to the body: parameter in these two methods, in the idsInBody branch, then the operations succeed.

Peter-Schorn commented 6 days ago

Hi Dan.

Thanks for bringing this to my attention! As far as I can remember, saveItemsForCurrentUser and removeItemsForCurrentUser always passed in a single top-level array of ids in the body. It looks like Spotify has made a breaking change to their API! I will implement your suggested change and release a new version shortly.

Peter-Schorn commented 6 days ago

Just pushed version 3.0.4, which should fix this issue. Please confirm that it is working on your end and I will close this issue.