title: AFNetworkingErrorDomain Code=-1011 "Request failed: internal server error (500)"
body: <p>I am using Afnetwork 2. I am a new one for IOS development. I want to connect some API using POST method. </p>
  
  <p>In this API I want set the Header as well.</p>
  
  <p>This is my code</p>
  
  <pre><code>AFHTTPSessionManager *manager = [[AFHTTPSessionManager alloc] initWithBaseURL:baseURL];
  
      manager.responseSerializer.acceptableContentTypes =[manager.responseSerializer.acceptableContentTypes setByAddingObject:@"text/html"];
      manager.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"text/html"];
      [manager.requestSerializer setValue:token forHTTPHeaderField:@"X-Auth-Token"];
      manager.responseSerializer = [AFJSONResponseSerializer serializer];
  
      [manager POST:@"api/v1/contact-group/add/" parameters:params
  
      success:^(NSURLSessionDataTask *task, id responseObject) {
  
  
      } failure:^(NSURLSessionDataTask *task, NSError *error) {
  
  
      }];
  </code></pre>
  
  <p>When I use this code I am getting the error like this</p>
  
  <pre><code>Error Domain=AFNetworkingErrorDomain Code=-1011 "Request failed: internal server error (500)" UserInfo=0xa8b0930 {NSErrorFailingURLKey=http://xxxxxx.info/api/v1/contact-group/add, NSLocalizedDescription=Request failed: internal server error (500), NSUnderlyingError=0xa88cb00 "Request failed: unacceptable content-type: text/html", AFNetworkingOperationFailingURLResponseErrorKey=&lt;NSHTTPURLResponse: 0xaa5a940&gt; { URL: http://xxxxxx.info/api/v1/contact-group/add } { status code: 500, headers {
      "Cache-Control" = "no-cache";
      Connection = close;
      "Content-Type" = "text/html";
      Date = "Thu, 12 Jun 2014 15:39:31 GMT";
      Server = Apache;
      "Set-Cookie" = "laravel_session=.....";
      "X-Frame-Options" = SAMEORIGIN;
      "X-Powered-By" = "PHP/5.3.28, PleskLin";
  } }}
  </code></pre>
  
  <p>I refer lot of documents and stackoverflow questions and answer. They gave lot of answers. But Unfortunately I didn't get the solution. Please help me.</p>
  
  <p>Please point my mistake. </p>
  
  <p>NOTE: When I use without header it will return "Invalid header". It will return correct error message. </p>
  
  <p><strong>EDIT</strong></p>
  
  <p>Server expecting format
  Method POST</p>
  
  <pre><code>input
  {
      "blog_guid": "k39453050345j",
      "contact_groups": [
          "er234we232",
          "tet343i49ti3409t33"
      ]
  }
  </code></pre>
  
  <p>server response</p>
  
  <pre><code>{
      "error": false,
      "code": 200,
      "message": "Success"
  }
  </code></pre>
  
  <p>I am sending parameters like this</p>
  
  <pre><code> NSMutableDictionary *params = [[NSMutableDictionary alloc]
                                     initWithObjects:@[guid, groupName, description]
                                     forKeys:@[APISEND_CONTACTGROUPKEY, APISEND_CONTACTGROUPNAME, APISEND_CONTACTGROUPDESCRIPTION]];
  </code></pre>