title: Using Cypher (Neo4j) within a REST API request (Objective C)
body: <p>I am trying to query my Neo4j database, using the REST API.</p>
  
  <p>I have this working so far without using the Cypher query language to retrieve data,
  however, now I need to get nodes which are sorted by 'newest' i.e. unix timestamp DESC.</p>
  
  <p>I have tried to add the query within the HTTP body of the <code>NSMutableURLRequest</code> but I am just getting the HTTP error <code>405</code>.</p>
  
  <p>Here is my code:</p>
  
  <p>NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"%@node/%i", EventsManagerDataURL, creatorID]];</p>
  
  <pre><code>NSLog(@"Connecting to URL: %@", url);
  
  NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url];
  
  NSString *jsonMap = @"{'query' : 'start x  = node(4,6,7) return x order by x.datestart,'params' : {}}";
  NSData *jsonData = [jsonMap dataUsingEncoding:NSUTF8StringEncoding];
  
  [request setHTTPMethod:@"POST"];
  
  [request setValue:@"application/json" forHTTPHeaderField:@"Accept"];
  [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
  [request setValue:[NSString stringWithFormat:@"%d", jsonData.length] forHTTPHeaderField:@"Content-Length"];
  
  [request setHTTPBody:jsonData];
  
  [NSURLConnection sendAsynchronousRequest:request queue:[[NSOperationQueue alloc] init] completionHandler:^(NSURLResponse *response, NSData *data, NSError *error){
  
      if (data){
          NSLog(@"%s. Data: %@", _cmd, [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]);
      } else {
          NSLog(@"Error: %@", error.localizedDescription);
      }
  }];
  </code></pre>