Closed ThabreshVivid closed 7 years ago
@ThabreshVivid If I understand correctly it should be something like:
let networking = Networking(baseURL: "http://httpbin.org")
networking.post("/post", parameters: ["emailID" : "info@info.com"]) { result in
}
Networking would automatically convert the parameters to JSON.
@3lvis here the 7th line I got the error. how to resolve this ?
@ThabreshVivid it's parts and needs an array of FormDataPart.
So change it to
networking.post("DriverPhotoUpload", parts: [part]) { result in
@3lvis How can I set the content type ??
like this, networking.post("DriverPhotoUpload", parameterType: .custom("multipart/form-data"), parameters: imageData) { result in
The content-type is automatically set for you, since you're using the parts method, it knows you want "multipart/form-data"
.
There's a simple example here.
https://github.com/3lvis/Networking/blob/master/Tests/POSTTests.swift#L116-L151
@3lvis thanks its working too good :)
How can I add this lines ?
let values = ["emailID": "info@info.com"] request.httpBody = try! JSONSerialization.data(withJSONObject: values)