title: AFNetworking JSON request to WCF REST service
body: <p>I'm using AFNetworking for my REST service (WCF). Here is code:</p>
  
  <pre><code>  NSDictionary *userName = [NSDictionary dictionaryWithObject:@"user" forKey:@"UserNameOrEmail"];
    NSDictionary *pass = [NSDictionary dictionaryWithObject:@"123" forKey:@"Password"];
    NSArray *credentials = [NSArray arrayWithObjects:userName,pass,nil];
    NSDictionary *params = [NSDictionary dictionaryWithObject:credentials forKey:@"request"];
  
  
    AFHTTPClient *client = [[AFHTTPClient alloc] initWithBaseURL:
    [NSURL URLWithString:@"http://server"]];
  
    [client postPath:@"/ProfileWebService.svc/login" parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) {
      NSString *text = [[NSString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding];
      NSLog(@"Response: %@", text);
  } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
      NSLog(@"%@", [error localizedDescription]);
  }];
  </code></pre>
  
  <p>but I get 400 HTTP Error.</p>
  
  <p>Using HTML and AJAX it looks like:</p>
  
  <pre><code>        $(document).ready(function () {
  
              $("#login_call").click(function () {
                  $.ajax({
                      type: 'POST',
                      url: 'http://server/ProfileWebService.svc/login',
                      contentType : 'application/json',
                      dataType: 'json',
                      data: JSON.stringify({request: {UserNameOrEmail: $('#login_username').val(), Password: $('#login_password').val()}}),
                      success: function (data) {
                          $('#login_result').val('Code: ' + data.LoginResult.Code + '\nFault String: ' + data.LoginResult.FaultString);
                      }
                  });
              });
  
          });
  </code></pre>
  
  <p>and works fine.     </p>
  
  <p>What's wrong with parameters.</p>