zmb3 / spotify

A Go wrapper for the Spotify Web API
Apache License 2.0
1.38k stars 292 forks source link

Unrecognised item type error when using fields on GetPlaylistItems #262

Open thechubbypanda opened 3 months ago

thechubbypanda commented 3 months ago

I'm calling

spotify.Client.GetPlaylistItems(ctx, id, spotify.Fields("items(track(id))"))

and I get the error:

unrecognized item type: 

I'm assuming this is because it's expecting to decode the rest of the fields that don't exist.

I'd expect it to just give me back tracks with only the id populated.

TimHi commented 3 months ago

I'm confused what spotify.Fields("items(track(id))") is in your case, are you passing a valid spotify playlist ID?

thechubbypanda commented 3 months ago

Yeah, the playlistID is valid. The call works fine without the Fields parameter. See the code here.

I'm trying to use this endpoint as follows: image

TimHi commented 3 months ago

I see, the unmarshaling of the JSON expects the item type, using the filter its missing in func (t *PlaylistItemTrack) UnmarshalJSON.

Also it doesnt work for filters like spotify.Fields("items(track(name))").

I guess when using a Field it can't be expected that the PlaylistItemTrack matches the received JSON.

thechubbypanda commented 3 months ago

So is there something we can do about this or is it a lost cause? Do other endpoints play nicely with the fields param?