spotify icon indicating copy to clipboard operation
spotify copied to clipboard

Unrecognised item type error when using fields on GetPlaylistItems

Open keval6b opened this issue 1 year ago • 4 comments

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.

keval6b avatar Jun 16 '24 15:06 keval6b

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

TimHi avatar Jun 19 '24 10:06 TimHi

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

keval6b avatar Jun 19 '24 21:06 keval6b

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.

TimHi avatar Jun 20 '24 10:06 TimHi

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

keval6b avatar Jun 28 '24 19:06 keval6b