alamofire

How to access value of __nssingleobjectarrayi in the following code

旧街凉风 提交于 2020-07-22 06:47:05
问题 I parsed a json and got a JSON Dictionary. { data = ( { bio = "<null>"; bookmarked = 35; id = 22; "last_seen" = { date = "2017-03-30 14:00:01"; timezone = "Asia/Kolkata"; "timezone_type" = 3; }; name = "Alex"; username = "Alex"; } );} I am trying to access username and date. I tried it doing let name = userData.value(forKeyPath: "data.username") print(username) By printing this, I am getting a __NSSingleObjectArrayI with the username. Optional(<__NSSingleObjectArrayI 0x6080000120b0>( Alex ) )

How to send a POST request with nested Dictionary in swift

烈酒焚心 提交于 2020-07-03 04:58:31
问题 I search 100s of posts on StackOverflow but can't find any correct answer can anyone help me to solve this mystery. let param : [String : Any]= [ "ServiceReqID" : 1, "WebUsersID" : customerID, "FirstName" : userName, "LastName" : "", "Company" : self.profileValues.customerCompanyName, "City" : self.profileValues.customerCityName, "Email" : self.profileValues.customerEmail, "ContactNo" : self.profileValues.customerContactNumber, "Country" : "Pakistan", "PackageChange" : 0, "AddressChange" : 0,

How to send a POST request with nested Dictionary in swift

自闭症网瘾萝莉.ら 提交于 2020-07-03 04:58:06
问题 I search 100s of posts on StackOverflow but can't find any correct answer can anyone help me to solve this mystery. let param : [String : Any]= [ "ServiceReqID" : 1, "WebUsersID" : customerID, "FirstName" : userName, "LastName" : "", "Company" : self.profileValues.customerCompanyName, "City" : self.profileValues.customerCityName, "Email" : self.profileValues.customerEmail, "ContactNo" : self.profileValues.customerContactNumber, "Country" : "Pakistan", "PackageChange" : 0, "AddressChange" : 0,

upload image from multipart-from-data using Alamofire '~> 5.0.0-beta.3'

有些话、适合烂在心里 提交于 2020-06-27 17:12:14
问题 func uploadImage(image: UIImage, imageUrl: String, imageExtension: String , responseData: @escaping (_ response: UploaderModel)-> ()) { var status : UploaderModel? let token = UserDefaults.standard.string(forKey: PrefKeys.loginToken) ?? "" let authorization = ["Authorization" : "Bearer \(token)"] let imageURl = "http://68.183.152.132/api/v1/stuff/uploader" //Parameter HERE let parameters = [ "garbageCollector": 0, "stuff_uuid": "2b4b750a-f4a6-4d61-84ce-7c42b5c030ee", "delete_file" : "" ] as

Alamofire 5 alternative to sessionDidReceiveChallenge

不打扰是莪最后的温柔 提交于 2020-06-16 17:26:27
问题 I have just shifted to Alamofire 5. Earlier I used URLSession and Certificate Pinner and to handle auth challenge I used delegate method of URLSessionDelegate with hash values func urlSession(_ session: URLSession, didReceive challenge: URLAuthenticationChallenge, completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) { print("being challanged! for \(challenge.protectionSpace.host)") guard let trust = challenge.protectionSpace.serverTrust else { print(

Alamofire 5 alternative to sessionDidReceiveChallenge

心不动则不痛 提交于 2020-06-16 17:25:19
问题 I have just shifted to Alamofire 5. Earlier I used URLSession and Certificate Pinner and to handle auth challenge I used delegate method of URLSessionDelegate with hash values func urlSession(_ session: URLSession, didReceive challenge: URLAuthenticationChallenge, completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) { print("being challanged! for \(challenge.protectionSpace.host)") guard let trust = challenge.protectionSpace.serverTrust else { print(

Swift 5 & Alamofire 5 : GET method ERROR: Alamofire.AFError.URLRequestValidationFailureReason.bodyDataInGETRequest(22 bytes)

两盒软妹~` 提交于 2020-05-17 06:32:25
问题 I am trying to get records from Database using Alamofire. I am sending parameters in GET request as below. let headers : HTTPHeaders = ["x-access-token": "\(t)","username":"\(Base.sharedManager.user)","password":"\(Base.sharedManager.pass)"] let parm : [String: Any] = ["search_str" : self!.searchStr] // let searchUrl = Base.sharedManager.URL+"questions/get/"+self!.searchStr let searchUrl = Base.sharedManager.URL+"questions/get/" AF.request(searchUrl, method: .get, parameters: parm, encoding

Alamofire POST request with headers

和自甴很熟 提交于 2020-05-13 07:51:29
问题 I am trying to make a post request with headers using Alamofire in Swift. However, I keep getting the extra parameter in method call error. I'm using version 4.5 of Alamofire. I'm unable to figure out the error. Please find the code attached let headers = ["Authorization": token, "Content-Type": "application/json"] Alamofire.request("http://localhost:8000/create", method: .post, parameters: parameters, encoding: JSONEncoding.default, headers: headers).responseJSON { response in } 回答1: Add

Alamofire POST request with headers

浪尽此生 提交于 2020-05-13 07:48:32
问题 I am trying to make a post request with headers using Alamofire in Swift. However, I keep getting the extra parameter in method call error. I'm using version 4.5 of Alamofire. I'm unable to figure out the error. Please find the code attached let headers = ["Authorization": token, "Content-Type": "application/json"] Alamofire.request("http://localhost:8000/create", method: .post, parameters: parameters, encoding: JSONEncoding.default, headers: headers).responseJSON { response in } 回答1: Add

Alamofire POST request with headers

倾然丶 夕夏残阳落幕 提交于 2020-05-13 07:48:23
问题 I am trying to make a post request with headers using Alamofire in Swift. However, I keep getting the extra parameter in method call error. I'm using version 4.5 of Alamofire. I'm unable to figure out the error. Please find the code attached let headers = ["Authorization": token, "Content-Type": "application/json"] Alamofire.request("http://localhost:8000/create", method: .post, parameters: parameters, encoding: JSONEncoding.default, headers: headers).responseJSON { response in } 回答1: Add