ios - Response failure when using AFHTTPRequestOperationManager -
When I tried to call the API (FHTPPRVAST Operation Manager) for authentication method with the exact username and password, the exact Received feedback and the method was successful. Then I tried with an invalid username and password, I'm getting a response.
I tried ASIHTTPEEEEEPP AP for the same method, so please check the request and feedback given below and advise me how to resolve this issue. But there is an invalid user feedback failure in AFHTTPRequestOperationManager. ASIHTTPRequest call sample: ]; Request.shouldAttemptPersistentConnection = No; [Request Security Mode: @ "Post"]; [Request addRequestHeader: @ "Encrypted" value: @ "app / x-www-form-URLXeded"]; [RequestRequestHeader Request: @ "Authority" Value: [ShareUtil Authorization Header]]; [Request addRequestHeader: @ "Accept" value: @ "Application / Jason"]; [Request setValidatesSecureCertificate: no]; [Request setPostValue: @ "pa" forKey: @ "type"]; [Request setPostValue: for user name: @ "user name"]; [Request setPostValue: for password: @ "password"]; [Delegate request set: Self]; [Set time timeset: 120]; [Self setimer]; [Requested SetFinishSchell: @Selector (ResponseAssureSecurity :)]; [Request [setfile secretary: @sillector (responseAssuserfile :); [after issuing]; // Cancel an asynchronous request [network crude addOperation: request];
The response is ASIHTTPRequest and method is success {"error": "invalid_grant", "error_description": "validating user unable sdsdds@gmail.com "} using AFHTTPRequestOperationManager call sample: AFHTTPRequestOperationManager response and method failure: Your failure block Because the API is returning your Httington to a HTPX code 400 and the FNetworking is interpreting correctly as an error. You can also get more detailed data from feedback by using the
AFHTTPRequestOperationManager * managerAF = [AFHTTPRequestOperationManager Manager]; NSDictionary * params = @ {@ "Type": @ "Pay", @ "Username": Username, @ "Password": Password}; [ManagerAF.requestSerializer Set Value: @ "App / JS" forHTTPHeaderField: @ "Accept"]; [ManagerAF.requestSerializer Set Value: @ "Application / X-www-Form-URLXode" for HTTP Headerfield: @ "Encrypt"]; [ManagerAF.requestSerializer Set Value: [shareUtil Authorization Header] forHTTPHeaderField: @ "Authority"]; ManagerAF.responseSerializer = [AFJSONResponseSerializer serializer]; ManagerAF.securityPolicy.allowInvalidCertificates = Yes; [[UIApplication ShareApp] SetNetworkActivisionIndicatorVijay: Yes]; [ManagerAF Post: [SharedUtil URLByKey: @ "A_URL"] Parameter: Parameter Success: ^ (AFHTTPRequestOperation * Operation, ID responseObject) {NSData * Data = [operation.responseString DataUsingEncoding: NSUTF8StringEncoding]; } [[UIApplication ShareApp] setNetworkActivityIndicatorVisible: no]; } Failure: ^ (FHTPPKAESTA Operation * Operation, NSERR * error) {NSLog (@ "error:% @", error); [Self-stop timer]; }];
Printing details of error: error domain = com.alamofire.error.serialization .response code = -1011 "Request failed: Bad request (400)" UserInfo = 0xd3b7670 {NSErrorFailingURLKey = https: //example.com/token, com.alamofire.serialization.response.error.response = & lt; NSHTTPURL Answer: 0xd29a010 & gt; {URL: https://example.com/token} {status code: 400, header {"cache-control" = "no-store"; Connection = "keep-alive"; "Content-type" = "app / jason; charset = utf-8"; Date = "Fri, 25 July 2014 05:15:19 GMT"; Pragma = "no-cache"; Server = "NGN / 1.6.0"; "Transfer-encoding" = detection; "X-Power-To" = "servlet / 3.0 JSP / 2.2 (Glassfish Server Open Source Edition 3.1.2.2 Java / Oracle Corporation / 1.7)"; }}, NSLocalizedDescription = Request Fail: Bad Request (400)}
responseData and
responseString properties of the given AFHTTPRequestOperation object in the failure block.
Comments
Post a Comment