简体   繁体   English

使用REST执行POST请求-如何使用Neo4j

[英]executing POST request using REST - how to do it with Neo4j

I'm trying to execute POST request using pure REST to my remote Neo4j server( I cannot use any Java specific REST bindings, JDBC etc because the code has to be ported to android and I have confirmed those do not work in Android Project ). 我正在尝试使用纯REST向我的远程Neo4j服务器执行POST请求(我不能使用任何特定于Java的REST绑定,JDBC等,因为必须将代码移植到android,并且我已经确认那些代码在Android Project中不起作用)。 I can connect to the server OK response is 200, however can't figure out how to create a node. 我可以连接到服务器,可以的响应是200,但是不知道如何创建节点。 I'm using Eclipse and this is my code: 我正在使用Eclipse,这是我的代码:

URL url = new URL(SERVER_ROOT_URI);
String rawData = "node";
String encodedData = URLEncoder.encode(rawData);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setDoOutput(true);
connection.setDoInput(true);
connection.setRequestMethod("POST"); 
connection.setRequestProperty("Content-Type", "application/json");
OutputStream os = connection.getOutputStream();
OutputStreamWriter writer = new OutputStreamWriter(os,Charset.forName("UTF-8"));
writer.write(rawData);

How do I create a simple node ? 如何创建一个简单的节点? I'm having a hard time to execute Neo4j specific POST request using Java, I have the example requests here: http://neo4j.com/docs/stable/rest-api-nodes.html but how do I actually use it in Java to create/get a node ?? 我很难使用Java执行Neo4j特定的POST请求,这里有示例请求: http : //neo4j.com/docs/stable/rest-api-nodes.html,但是我如何在其中实际使用它Java创建/获取节点 I cannot find any samples 我找不到任何样品

This may be helpful: http://neo4j.com/docs/stable/server-java-rest-client-example.html 这可能会有所帮助: http : //neo4j.com/docs/stable/server-java-rest-client-example.html

Essentially this document from neo4j is demonstrating how to perform cypher queries directly as well as more advanced rest API requests using Jersey ( https://jersey.java.net/ ). 本质上,来自neo4j的该文档说明了如何使用Jersey( https://jersey.java.net/ )直接执行密码查询以及更高级的rest API请求。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM