Skip to content

Commit 391af49

Browse files
committed
Fixed a bug with the create playlist endpoint in which omitting a description causes the description of the playlist to be the string null. See issue #75.
1 parent 29329ba commit 391af49

4 files changed

Lines changed: 22 additions & 4 deletions

File tree

.swiftpm/xcode/xcshareddata/xcschemes/SpotifyAPI-Package.xcscheme

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "1620"
3+
LastUpgradeVersion = "1630"
44
version = "1.7">
55
<BuildAction
66
parallelizeBuildables = "YES"

.swiftpm/xcode/xcshareddata/xcschemes/SpotifyAPI.xcscheme

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "1620"
3+
LastUpgradeVersion = "1630"
44
version = "1.7">
55
<BuildAction
66
parallelizeBuildables = "YES"

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
44

55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## [4.0.2] - 05/08/2025
8+
9+
* Fixed a bug with the create playlist endpoint in which omitting a description causes the description of the playlist to be the string `null`. See issue [#75](https://github.com/Peter-Schorn/SpotifyAPI/issues/75).
10+
711
## [4.0.1] - 12/25/2024
812

913
* Fixed a bug in which certain characters, such as the `+` character, were not being properly percent-encoded in `Dictionary.formURLEncoded()`. See [#70](https://github.com/Peter-Schorn/SpotifyAPI/pull/70).

Sources/SpotifyWebAPI/API/SpotifyAPI+Playlists.swift

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -862,13 +862,27 @@ public extension SpotifyAPI where
862862
let userId = try SpotifyIdentifier(
863863
uri: userURI, ensureCategoryMatches: [.user]
864864
).id
865-
865+
866+
// There is a bug with the spotify web API where if the description
867+
// field is omitted entirely from the JSON (as opposed to explicitly
868+
// setting it to null), then the description of the playlist will be
869+
// the string `null`.
870+
// See issue #75.
871+
let modifiedPlaylistDetails = PlaylistDetails(
872+
name: playlistDetails.name,
873+
isPublic: playlistDetails.isPublic,
874+
isCollaborative: playlistDetails.isCollaborative,
875+
description: playlistDetails.description == nil
876+
? ""
877+
: playlistDetails.description
878+
)
879+
866880
return self.apiRequest(
867881
path: "/users/\(userId)/playlists",
868882
queryItems: [:],
869883
httpMethod: "POST",
870884
makeHeaders: Headers.bearerAuthorizationAndContentTypeJSON(_:),
871-
body: playlistDetails,
885+
body: modifiedPlaylistDetails,
872886
requiredScopes: []
873887
)
874888
.decodeSpotifyObject(

0 commit comments

Comments
 (0)