2

I am using Alamofire 3.0 The following is my code

var ignoreIDs = [Int]()
self.ignoreIDs.append(2)
let parameters = ["ignore_ids": self.ignoreIDs]
Alamofire.request(.GET, AppDelegate.kbaseUrl + "surveys/me", parameters: parameters, encoding: .JSON)
    .responseJSON {
        response in
    }

However, the result of print(response.result) just shows FAILURE. Is there any way to get more information? Also, is this the correct way to pass an array as parameters? P/S: Yes server side is indeed expecting an array.

7
  • For more information you may do this: .responseJSON { (request, response, json, error) in instead .responseJSON { response in. And print all params you need Commented Oct 18, 2015 at 9:05
  • Is it just me or you can't do that since Alamofire 2.0? I'm using Alamofire 3.0 Commented Oct 18, 2015 at 9:19
  • I did not know that this does not work in 3.0. I use old version. I'm sorry for the wrong information Commented Oct 18, 2015 at 9:22
  • add the exact format of array which server is expecting and also the returning result from server as well Commented Oct 18, 2015 at 10:15
  • Johnny can you elaborate a bit? At least how can I get more info at this point? Commented Oct 18, 2015 at 10:22

2 Answers 2

2

To print out additional information about the result, you should use debugPrint(response.result).

var ignoreIDs = [Int]()
self.ignoreIDs.append(2)
let parameters = ["ignore_ids": self.ignoreIDs]

Alamofire.request(.GET, AppDelegate.kbaseUrl + "surveys/me", parameters: parameters, encoding: .JSON)
    .responseJSON { response in
        debugPrint(response)
        debugPrint(response.result)
    }

Both of these are overridden to provide more detail about the actual response.

Sign up to request clarification or add additional context in comments.

Comments

0

sorry apparently it's my own fault. My method is a GET, so as Johnny mentioned I'm parsing in a form that the server wasn't expecting.

The answer for me should be append the parameters as a query string and to my base url.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.