title: STHTTPRequest how to postData not Key-Value?
body: <p>I try using STHTTPRequest to post JSON Object:</p>
  
  <pre><code>{
   "login":"name",
   "password":"password"
  }
  </code></pre>
  
  <p>how i can do it?</p>
  
  <p>I write ios code:</p>
  
  <pre><code>STHTTPRequest * request=[STHTTPRequest requestWithURLString:@"http://moscow2013.hol.es/test.php"];
  request.completionBlock=^(NSDictionary *headers, NSString *body) {
      NSLog(@"Data:%@",body);
  };
  request.errorBlock=^(NSError *error) {
      NSLog(@"Error:%@",error);
  
  };
  
  NSMutableDictionary *postData=[[NSMutableDictionary alloc] init];
  NSMutableDictionary *data=[[NSMutableDictionary alloc] init];
  [data setValue:@"a3bc5193-60b2-4f61-8f2d-a24b01423cb1" forKey:@"login"];
  [data setValue:udid forKey:@"udid"];
  [postData setValue:data forKey:@"data"];
  request.encodePOSTDictionary=NO;
  request.POSTDictionary=postData;
  request.postDataEncoding=NSUTF8StringEncoding;
  [request startAsynchronous];
  </code></pre>
  
  <p>But on server i got:</p>
  
  <pre><code>Array
  (
      [data] =&gt; {
      login = "a3bc5193-60b2-4f61-8f2d-a24b01423cb1";
      udid = "4D6A3ABF-29CF-4D79-9716-BBBD8160626F";
  }
  )
  </code></pre>
  
  <p>How me send json as object?</p>
  
  <p>I do next:</p>
  
  <pre><code>NSString *jsonString =nil;
  NSError *error;
  NSData *jsonData = [NSJSONSerialization dataWithJSONObject:data
                                                     options:NSJSONWritingPrettyPrinted
                                                       error:&amp;error];
  if (! jsonData) {
      NSLog(@"Got an error: %@", error);
  } else {
      jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
  }
  
  NSMutableURLRequest *request2 = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"http://moscow2013.hol.es/horeca.php"]];
  [request2 setHTTPMethod:@"POST"];
  [request2 setValue:@"application/json; charset=utf-8" forHTTPHeaderField:@"content-type"];
  //this is hard coded based on your suggested values, obviously you'd probably need to make this more dynamic based on your application's specific data to send
  NSString *postString = jsonString;
  NSData *data2 = [postString dataUsingEncoding:NSUTF8StringEncoding];
  [request2 setHTTPBody:data2];
  [request2 setValue:[NSString stringWithFormat:@"%u", [data2 length]] forHTTPHeaderField:@"Content-Length"];
  [NSURLConnection connectionWithRequest:request2 delegate:self];
  NSData *retData=    [NSURLConnection sendSynchronousRequest:request2 returningResponse:nil error:nil];
  
  NSString *retDataStr=[[NSString alloc] initWithData:retData encoding:NSUTF8StringEncoding];
  NSLog(@"%@",retDataStr);
  </code></pre>
  
  <p>And then on server side i got my correct json.</p>