0
我想使用REST API查詢我的Neo4j數據庫。在REST API請求(目標C)中使用Cypher(Neo4j)
到目前爲止,我沒有使用Cypher查詢語言檢索數據,但是,現在我需要獲取按'最新'排序的節點,即unix timestamp DESC。
我試圖在NSMutableURLRequest
的HTTP正文中添加查詢,但我只是得到HTTP錯誤405
。
這是我的代碼:
NSURL * URL = [NSURL URLWithString:[的NSString stringWithFormat:@ 「%@節點/%I」,EventsManagerDataURL,的creatorID]];
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);
}
}];
感謝您的回覆,cURL似乎有效,但是,我仍然得到了4 05'錯誤在我的'NSLog'中:/ –
它是否給405錯誤文本? –
請確保您的網址是正確的。我以前遇到過問題。 –