0

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 ). I can connect to the server OK response is 200, however can't figure out how to create a node. I'm using Eclipse and this is my code:

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 ?? I cannot find any samples

Dodi
  • 2,201
  • 4
  • 30
  • 39

1 Answers1

1

This may be helpful: 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/).