alamofire

getting error message from server during API call

瘦欲@ 提交于 2020-01-05 04:15:11
问题 I have an app where I used RxSwift for my networking by extending ObservableType this works well but the issue I am having now is when I make an API request and there is an error, I am unable to show the particular error message sent from the server. Now how can I get the particular error response sent from the server extension ObservableType { func convert<T: EVObject>(to observableType: T.Type) -> Observable<T> where E: DataRequest { return self.flatMap({(request) -> Observable<T> in let

Alamofire in Swift: converting response data in usable JSON dictionary

ε祈祈猫儿з 提交于 2020-01-04 14:01:23
问题 I would like to handle a JSON string that is returned as data from a HTTP call made using Alamofire . This question uses SwiftyJSON. However I wanted to go a little bit "lower level" and understand how to convert the response object into a dictionary. Reasoning is that it feels that a dictionary may be a simple / easy way to access to the JSON values in the response (rather than having to go through the process of converting the response to a JSON object). This is under the assumption that

iOS 13 adds “trim.” prefix to files selected from UIImagePickController

被刻印的时光 ゝ 提交于 2020-01-04 06:12:40
问题 iOS 13 adds a trim. prefix when selecting a file from Photos: file:///private/var/mobile/Containers/Data/PluginKitPlugin/FPDLKFHEQ-4T56-3456-HTE2-39EK2KDJUR/tmp/trim.DFLSPD0F-32RE-UYI8-DFHA-DPFLEOW098UH.MOV Before iOS-13 was like this: file:///private/var/mobile/Containers/Data/PluginKitPlugin/FPDLKFHEQ-4T56-3456-HTE2-39EK2KDJUR/tmp/DFLSPD0F-32RE-UYI8-DFHA-DPFLEOW098UH.MOV This is an issue when passing the file URL to alamofire to upload the file to a backend server. It causes an "unknown

iOS 13 adds “trim.” prefix to files selected from UIImagePickController

情到浓时终转凉″ 提交于 2020-01-04 06:11:15
问题 iOS 13 adds a trim. prefix when selecting a file from Photos: file:///private/var/mobile/Containers/Data/PluginKitPlugin/FPDLKFHEQ-4T56-3456-HTE2-39EK2KDJUR/tmp/trim.DFLSPD0F-32RE-UYI8-DFHA-DPFLEOW098UH.MOV Before iOS-13 was like this: file:///private/var/mobile/Containers/Data/PluginKitPlugin/FPDLKFHEQ-4T56-3456-HTE2-39EK2KDJUR/tmp/DFLSPD0F-32RE-UYI8-DFHA-DPFLEOW098UH.MOV This is an issue when passing the file URL to alamofire to upload the file to a backend server. It causes an "unknown

Not working - Registering User in Api Programatically in Swift 3/4

时间秒杀一切 提交于 2020-01-04 03:27:09
问题 I'm trying to register a user in my API. When I do it in Postman, it registers the user and returns the status as true and message as User Created, but when I try to create a new user from swift programatically it always shows User already exists (giving false response), even though it is not registered. I'm Using Swift 4 Xcode 9. The almost same code work works for Sign In Api, but not working for User Registration. Also, after I register that user through postman in Api, it works perfectly

How to get error statusCode from `MoyaError`?

我们两清 提交于 2020-01-03 21:09:14
问题 I'm using a Moya , Moya_ModelMapper and RxSwift to perform network requests. Here is my example code: let provider = RxMoyaProvider<MyEndpoint>() let observable: Observable<RegistrationResponse> = provider.request(.register(firstName: "", lastName: "", email: "", password: "")).mapObject(type: RegistrationResponse.self) observable.subscribe { [weak self] (event: Event<RegistrationResponse>) in switch event { case .next(let response): print(response) case .error(let error): print(error) case

How to get error statusCode from `MoyaError`?

≯℡__Kan透↙ 提交于 2020-01-03 21:09:13
问题 I'm using a Moya , Moya_ModelMapper and RxSwift to perform network requests. Here is my example code: let provider = RxMoyaProvider<MyEndpoint>() let observable: Observable<RegistrationResponse> = provider.request(.register(firstName: "", lastName: "", email: "", password: "")).mapObject(type: RegistrationResponse.self) observable.subscribe { [weak self] (event: Event<RegistrationResponse>) in switch event { case .next(let response): print(response) case .error(let error): print(error) case

Swift Custom Response Serializer is returning images at random

笑着哭i 提交于 2020-01-03 02:51:10
问题 I am currently using Alamofire to Fetch Json data/url-images from a Server. I also created a custom response serializer using this tutorial to convert url images into UIImages upon request. Everything works fine, and I am able to load all of the Images from the server into a UIImageView. The user can then swipe from left to right in order to View each image like a Photo Gallery. The Problem I am having is that my custom response returns the images in a different order. Therefore, every image

Swift - multiple Chain http request with loop

半世苍凉 提交于 2020-01-02 16:18:20
问题 Since 2 days it feels that I'm searching the whole web to solve my problem with multiple http requests. So my workflow looks like this: Upload a image to a server Response = XML Format with a Task ID GET request to the server with the Task ID to check the status of this task. Response = XML Format where the status could be "Completed", "In Progress", "Queued" If Status != "Completed" - retry step 2 If Status == "Completed" - go to step 3 Download the result from the resultUrl My last try was

GoogleDrive + Alamofire: Uploading a file with properties

此生再无相见时 提交于 2020-01-02 09:29:10
问题 I am trying to upload a file + parameters to Google Drive via Swift 2/Alamofire. In the code below, i I change the line that says: "https://www.googleapis.com/upload/drive/v3/files?uploadType=multipart" to the following: "https://www.googleapis.com/upload/drive/v3/files" the file uploads to google without a name. Otherwise, the file upload fails with the same generic code: Error Domain=com.alamofire.error Code=-6003 "Response status code was unacceptable: 400" UserInfo=