Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS POST with AFNetworking : NSLocalizedDescription=Request failed: internal server error (500)

I have a UITextField and I want to update my server when I write something in UITextField and press update button, I used AFNetworking, but I have an error :

 Domain=com.alamofire.error.serialization.response Code=-1011 
 "Request failed: internal server error (500)
{ status code: 500, headers {
"Access-Control-Allow-Headers" = "Origin, X-Requested-With, Content-Type, Accept";
"Access-Control-Allow-Methods" = "OPTIONS,GET,POST,PUT,DELETE";
"Access-Control-Allow-Origin" = "*";
Connection = "keep-alive";
"Content-Type" = "text/plain";
Date = "Thu, 24 Jul 2014 00:41:56 GMT";
Server = Cowboy;
"Transfer-Encoding" = Identity;
Via = "1.1 vegur";
"X-Powered-By" = Express;
} }, NSLocalizedDescription=Request failed: internal server error (500)}

Here is my Update button code:

AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
manager.responseSerializer = [AFHTTPResponseSerializer serializer];
manager.requestSerializer = [AFJSONRequestSerializer serializer];


NSDictionary *params = @ {@"status" :_status};


[manager POST:BASE_URL parameters:params
      success:^(AFHTTPRequestOperation *operation, id responseObject)
 {
     NSLog(@"JSON: %@", responseObject);
 }
      failure:
 ^(AFHTTPRequestOperation *operation, NSError *error) {
     NSLog(@"Error: %@", error);
 }];

Appreciated any help!

like image 729
Sara Shumika Avatar asked Nov 26 '22 07:11

Sara Shumika


1 Answers

Error code, -1011 means kCFURLErrorBadServerResponse (from docs). Your web service (API) giving you response for which your request/response serializer of AFNetworking doesn't know. Ask your developer team to see and correct the error.

like image 71
Hemang Avatar answered Jan 16 '23 04:01

Hemang