Reputation: 1258
I'm constructing multipart form-data request. I'm getting build error for append statements
var dataBody = Data()
dataBody.append("--\(boundary + lineBreak)") //Error
Error: Cannot invoke 'append' with an argument list of type '(String)'
It's weird as this works in other project. Am I missing something? How to fix this issue?
Upvotes: 0
Views: 53
Reputation: 100523
You're trying to append a string to a Data
object which won't compile , you need to convert this string first to Data
with proper encoding .utf8
here like this
var dataBody = Data()
let str = "--\(boundary + lineBreak)"
dataBody.append(Data(str.utf8))
Upvotes: 3