title: NSURLSession POST is not working and returning 500 status code in iphone
body: <p>When i am using NSURLSession while Posting through the Browser is returning the result as 200 status but when i send it through code in IOS i am getting 500 status code as below.</p>
  
  <pre><code>Response:&lt;NSHTTPURLResponse: 0x14e754240&gt; { URL: urlAPI } { status code: 500, headers {
      "Cache-Control" = private;
      "Content-Length" = 30;
      "Content-Type" = "text/plain; charset=utf-8";
      Date = "Thu, 28 Jan 2016 12:59:10 GMT";
      Server = "Microsoft-IIS/7.5";
      "X-AspNet-Version" = "4.0.30319";
      "X-Powered-By" = "ASP.NET";
  } } 
  </code></pre>
  
  <p>Below is my code </p>
  
  <pre><code>NSURLSessionConfiguration *defaultConfigObject = [NSURLSessionConfiguration defaultSessionConfiguration];
     NSURLSession *defaultSession = [NSURLSession sessionWithConfiguration: defaultConfigObject delegate: nil delegateQueue: [NSOperationQueue mainQueue]];
  
     NSURL * url = [NSURL URLWithString:@"HERE IS MY URL"];
     NSMutableURLRequest * urlRequest = [NSMutableURLRequest requestWithURL:url];
     NSString * params =@"MY PARAMETERS";
     [urlRequest setHTTPMethod:@"POST"];
     [urlRequest setHTTPBody:[params dataUsingEncoding:NSUTF8StringEncoding]];
  
     NSURLSessionDataTask * dataTask =[defaultSession dataTaskWithRequest:urlRequest
                                         completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
                                           NSLog(@"Response:%@ %@\n", response, error);
                                           if(error == nil)
                                           {
                                               NSString * text = [[NSString alloc] initWithData: data encoding: NSUTF8StringEncoding];
                                               NSLog(@"Data = %@",text);
                                           }
  
                                       }];
     [dataTask resume];
  </code></pre>
  
  <p>This code worked previously but it is throwing error now(API code also not changed),where am i doing wrong.Help me out of this.</p>