Skip to content

Commit 63dbd45

Browse files
Use JSON encoding for post and put requests.
1 parent 947935a commit 63dbd45

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

Networking/Networking/Requests/RESTRequest.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,12 @@ struct RESTRequest: URLRequestConvertible {
5353
let components = [siteURL, Settings.basePath, wooApiVersion.path, path].map { $0.trimSlashes() }
5454
let url = try components.joined(separator: "/").asURL()
5555
let request = try URLRequest(url: url, method: method)
56-
return try URLEncoding.default.encode(request, with: parameters)
56+
switch method {
57+
case .post, .put:
58+
return try JSONEncoding.default.encode(request, with: parameters)
59+
default:
60+
return try URLEncoding.default.encode(request, with: parameters)
61+
}
5762
}
5863
}
5964

0 commit comments

Comments
 (0)