Shoeb Shaikh Shoeb Shaikh - 20 days ago 7
Swift Question

I am using Swift-SRWebClient to upload multiple images in single post but i am not able to do so with swift 2.2? using REST API

Here is my code :

SRWebClient.POST("http://www.tiikoni.com/tis/upload/upload.php").data(messageData, fieldName:"photo", data: ["CreatedBy":"4","Name": "Test", "Description" :"Test","CategoryId": "0", "SendToSupplier":"0","DeliveryDate":"25/10/2016","FileExtension":"png"])
.send({(response:AnyObject!, status:Int) -> Void in
// process success response
},failure:{(error:NSError!) -> Void in
// process failure response
})


This method gives me the error


Cannot invoke with an argument list of type .....

Answer
SRWebClient.POST("YOUR URL/M/API").data(YorARRAYOFIMAGEDATA,
                                        fieldName:"photo",
                                        data: [
                                            "CreatedBy":"4",
                                            "Name": "Test",
                                            "Description" :"Test",
                                            "CategoryId": "0",
                                            "Parameters":"0",
                                            "DeliveryDate":"25/10/2016",
                                            "FileExtens‌​ion":"png"
    ])
    .send({(response:AnyObject!, status:Int) -> Void in
        print("Success")
        self.navigationController?.popFadeToRootViewController()
    }, failure: {(error:NSError!) -> Void in
        print("failure")
    }
)
Comments