title: Getting error "Error Domain=com.alamofire.error.serialization.response Code=-1011 "Request failed: bad request (400)" in iOS 7
body: <p>I am using <strong>AFNetworking</strong> version "2.5.4" and creating <strong>multipartform-data</strong>  request. 
  In my case code is working fine on iOS8 but issue on iOS 7. Getting Error </p>
  
  <blockquote>
    <p>"Error Domain=com.alamofire.error.serialization.response Code=-1011
    "Request failed: bad request (400)"</p>
    
    <p>UserInfo=0x19039c00
    {com.alamofire.serialization.response.error.response= { URL: <a href="http://xxx/api/abc/PostApi" rel="nofollow noreferrer">http://xxx/api/abc/PostApi</a> } { status code: 400,
    headers {
        Connection = close;
        "Content-Type" = "application/json";
        Date = "Wed, 20 May 2015 05:42:47 GMT";
        Server = Apache; } }, NSErrorFailingURLKey=<a href="http://xxx/api/abc/PostApi" rel="nofollow noreferrer">http://xxx/api/abc/PostApi</a> },
    NSLocalizedDescription=Request failed: bad request (400),
    com.alamofire.serialization.response.error.data=&lt;7b227375 63636573
    73223a66 616c7365 2c226d65 73736167 65223a22 4e6f2064 61746122
    2c226461 7461223a 5b5d2c22 72657370 6f6e7365 5f636f64 65223a22
    52433030 3033227d>}</p>
  </blockquote>
  
  <p>This is my Code that have issue </p>
  
  <p>`       </p>
  
  <pre><code>@property (strong, nonatomic) NSURLSessionUploadTask *postUploadTask;
  
  __block int i=1;
              AFURLSessionManager *manager = [[AFURLSessionManager alloc] initWithSessionConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]];
  
      NSMutableURLRequest *request = [[AFHTTPRequestSerializer serializer] multipartFormRequestWithMethod:@"POST" URLString:urlString parameters:postParameters constructingBodyWithBlock:^(id&lt;AFMultipartFormData&gt; formData) {
          if (imageArray.count &gt; 0) {
              long dataLenght = 0.0;
              for(UIImage *eachImage in imageArray)
              {
                  NSData *imageData = UIImageJPEGRepresentation(eachImage, .5);
                  dataLenght = dataLenght + imageData.length;
                  [formData appendPartWithFileData:imageData name:[NSString stringWithFormat:@"image%d",i] fileName:[NSString stringWithFormat:@"image%d.jpg",i] mimeType:@"image/jpeg"];
                  i++;
              }
  
          }
      } error:nil];
  
      NSProgress *progress = nil;
      self.postUploadTask = [manager uploadTaskWithStreamedRequest:request progress:&amp;progress completionHandler:^(NSURLResponse *response, id responseObject, NSError *error) {
          [progress removeObserver:object forKeyPath:kProgressFractionCompleted context:kPostUpdateTypePostUpdate];
          completionBlock(responseObject, error, task);
      }];
      [self.postUploadTask resume];` 
  </code></pre>
  
  <p>While this is working code on same api-:</p>
  
  <pre><code>     AFHTTPRequestOperationManager *manager = [[AFHTTPRequestOperationManager alloc] initWithBaseURL:[NSURL URLWithString:BASE_URL]];
  
      AFHTTPRequestOperation *op = [manager POST:urlString parameters:postParameters constructingBodyWithBlock:^(id&lt;AFMultipartFormData&gt; formData) {
          if (imageArray.count &gt; 0) {
              long dataLenght = 0.0;
              for(UIImage *eachImage in imageArray)
              {
                  NSData *imageData = UIImageJPEGRepresentation(eachImage, .5);
                  dataLenght = dataLenght + imageData.length;
                  [formData appendPartWithFileData:imageData name:[NSString stringWithFormat:@"image%d",i] fileName:[NSString stringWithFormat:@"image%d.jpg",i] mimeType:@"image/jpeg"];
                  i++;
              }
          }
      } success:^(AFHTTPRequestOperation *operation, id responseObject){
  
          completionBlock(responseObject, nil, task);
  
          [progress removeObserver:object forKeyPath:kProgressFractionCompleted context:kPostUpdateTypePostUpdate];
  
      } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
          completionBlock(operation, error, task);
  
      }];
      [op start];
  </code></pre>
  
  <p>But My requirement is to implement uploadTaskWithStreamedRequest. 
  This is similar to issue"<a href="https://stackoverflow.com/questions/26235270/error-domain-com-alamofire-error-serialization-response-code-1011-request-fail">Error Domain=com.alamofire.error.serialization.response Code=-1011 &quot;Request failed: bad request (400)</a>". </p>
  
  <p>Please help me guys if have any idea about it. Thanks in advance.</p>