RestAPI response is not same as Postman Response

I am facing a very strange issue while calling RESTful API. I have a login API, I tested it in Postman and it's working perfectly fine. Here is a screenshot.

enter image description here

But once I call it using Alamofire, I get the response as "status :" 1 and "message" : 'Incorrect Credentials' It's the same email and password that I'm using in postman but still I get this response even though my email and password is correct. I have tested it on multiple email and passwords, and for every user it gives me same error.

Here is my login Function..

 public func login(email: String, password: String, success: @escaping (UserData) -> (), failure: errorClosure)
        let parameters: Parameters = [
            "email": "\(email)",
            "password": "\(password)"
        session.request(Config.loginURL, method: .post, parameters: parameters, encoding: JSONEncoding.default).responseJSON
            { response in
            switch response.result
            case .success(_):
                let json = response.value
                print("JSON: \(json ?? "errr")")
                MappingHelper.ModelFromResponse(UserData.self, response: response, success: { (result) in
                }, failure: failure)
            case .failure(let error):

This is how i'm calling it..

helper.login(email: email, password: password) { (UserData) in
        } failure: { (error) in


enter image description here

enter image description here

The reason I am using session.request instead of AF.request is because when I use AF.request it throws me a certificate error.

The certificate for this server is invalid. You might be connecting to a server that is pretending to be "DOMAIN NAME" which could put your confidential information at risk.

So to bypass this error I created a session with the help of some answer from SO.

private let session: Session = {
        let manager = ServerTrustManager(evaluators: ["******.com": DisabledTrustEvaluator()])
        let configuration =
        return Session(configuration: configuration, serverTrustManager: manager)

Read more here:

Content Attribution

This content was originally published by NaveedUlHassan5 at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: