title: POST request using application/x-www-form-urlencoded
body: <p>The back end developer had given these instructions in POST requests:</p>
  
  <ol>
  <li>Route: {url}/{app_name/{controller}/{action}</li>
  <li>The controller and action should be on small caps. </li>
  <li>API test link: http:<strong><em>*</em>**<em>*</em>**<em>*</em>**<em>*</em>**<em>*</em>***</strong></li>
  <li>Request should be use POST Method.</li>
  <li>Parameters should be pass via request content body (FormUrlEncodedContent).</li>
  <li>Parameters should be on json format.</li>
  <li>Parameters are key sensitive.</li>
  </ol>
  
  <p>Having no experience with number 5 in the protocol, I searched and ended with my code.</p>
  
  <pre><code>-(id)initWithURLString:(NSString *)URLString withHTTPMEthod:(NSString *)method withHTTPBody:(NSDictionary *)body {
  
      _URLString = URLString;
      HTTPMethod = method;
      HTTPBody = body;
  
      //set error message
      errorMessage = @"Can't connect to server at this moment. Try again later";
      errorTitle = @"Connection Error";
  
      return  self;
  }
  
  
  -(void)fireConnectionRequest {
  
      NSOperationQueue *mainQueue = [[NSOperationQueue alloc] init];
      [mainQueue setMaxConcurrentOperationCount:5];
  
      NSError *error = Nil;
  
      NSURL *url = [NSURL URLWithString:_URLString];
      NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url];
  
      NSData *sendData = [NSJSONSerialization dataWithJSONObject:HTTPBody options:NSJSONWritingPrettyPrinted error:&amp;error];
      [request setHTTPMethod:@"POST"];
  
      [request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
      [request setValue:@"application/json" forHTTPHeaderField:@"Accept"];
  
      [request setHTTPBody: sendData];
      [NSURLConnection connectionWithRequest:request delegate:self];
  
      NSString *jsonString = [[NSString alloc]initWithData:sendData encoding:NSUTF8StringEncoding];
  
  
      //fire URL connectiion request
      [NSURLConnection sendAsynchronousRequest:request queue:mainQueue completionHandler:^(NSURLResponse *response, NSData *responseData, NSError *error) {
  
          //get the return message and transform to dictionary
          NSString *data = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];
          returnMessage = [NSJSONSerialization JSONObjectWithData: [data dataUsingEncoding:NSUTF8StringEncoding]
                                                          options: NSJSONReadingMutableContainers
                                                            error:&amp;error];
  
  
          //check return message
          if (!error) {
              [delegate returnMessageForTag:self.tag];
  
          }
          else {
              [delegate returnErrorMessageForTag:self.tag];
          }
  
      }];
  
  }
  </code></pre>
  
  <p>I pass a dictionary formatted to JSON. he agrees that I was able to pass the right data. And I was able to connect to the API, but it is always returning "FAILED" when I try send data for registration. There are no problems in connection, but I failed to transfer the data.</p>
  
  <p>The android developer here using the same API has no problem with it, but wasn't able to help me out since he's not familiar with iOS.</p>
  
  <p>What am I missing?</p>