[Solved] How to make this HTTP Post request using alamofire? [closed]

let url = “192.168.1.1/api/project” var header = [String:String]() header[“accept”] = “aplication/json” header[“key”] = “David” let reqParam = [“project”:[“title”:”Test Title”,”description”:”Test description for new project”,”priority”:false,”category_id”:1,”location_id”:1]] Alamofire.upload(multipartFormData: { multipartFormData in for (key, value) in reqParam{ do{ let data = try JSONSerialization.data(withJSONObject: value, options: .prettyPrinted) multipartFormData.append(data, withName: key) }catch(let err){ print(err.localizedDescription) } } },usingThreshold:UInt64.init(), to: url, method: .post, headers: … Read more

[Solved] Variable keeps returning nil – Swift iOS

All your suggestions were valid but this is what actually worked. import Foundation import Alamofire class GreetingObjectHandler { var greetings: [Greeting] = [] init(filename: String) { let fileP = NSURL(string: “http://localhost:2403/users/me”) let jsonD = NSData(contentsOfURL:fileP!) let jso = JSON(data: jsonD!, options: NSJSONReadingOptions.AllowFragments, error: nil) var id = jso[“id”] let filePath = NSURL(string: “http://localhost:2403/users”) let jsonData … Read more