title: Error:Error Domain=NSCocoaErrorDomain Code=3840 "The operation couldn’t be completed.
body: <p>I am trying to upload a image using AFHTTPSessionManager through REST API call.</p>
  
  <p>following are my code</p>
  
  <pre><code>    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
      manager.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"text/html"];
      [manager.requestSerializer setValue:@"image/jpeg" forHTTPHeaderField:@"Content-Type"];
      NSData *imageData = UIImageJPEGRepresentation(image, 0.5);
  
      [manager POST:@"http://localhost:8888/uploadImage/100" parameters:nil constructingBodyWithBlock:^(id formData) {
          [formData appendPartWithFileData:imageData name:@"avatar" fileName:@"avatar.jpg" mimeType:@"image/jpeg"];
      } success:^(NSURLSessionDataTask *task, id responseObject) {
          NSLog(@"success:%@", responseObject);
      } failure:^(NSURLSessionDataTask *task, NSError *error) {
          NSLog(@"Error:%@", error);
      }];
  </code></pre>
  
  <p>Response is going to field block and getting following error </p>
  
  <p>Error:Error Domain=NSCocoaErrorDomain Code=3840 "The operation couldn’t be completed. (Cocoa error 3840.)" (JSON text did not start with array or object and option to allow fragments not set.) UserInfo=0x9cbc690 {NSDebugDescription=JSON text did not start with array or object and option to allow fragments not set., NSUnderlyingError=0x9cbaf00 "Request failed: length required (411)"}</p>
  
  <p>Any one have idea on this issue ?</p>
  
  <p>Thanks</p>