Create node
Example request
-
POSThttp://localhost:7474/db/data/node -
Accept:application/json; charset=UTF-8
Example response
-
201:Created -
Content-Type:application/json; charset=UTF-8 -
Location:http://localhost:7474/db/data/node/18
{
"extensions" : { },
"metadata" : {
"id" : 18,
"labels" : [ ]
},
"paged_traverse" : "http://localhost:7474/db/data/node/18/paged/traverse/{returnType}{?pageSize,leaseTime}",
"outgoing_relationships" : "http://localhost:7474/db/data/node/18/relationships/out",
"outgoing_typed_relationships" : "http://localhost:7474/db/data/node/18/relationships/out/{-list|&|types}",
"create_relationship" : "http://localhost:7474/db/data/node/18/relationships",
"labels" : "http://localhost:7474/db/data/node/18/labels",
"traverse" : "http://localhost:7474/db/data/node/18/traverse/{returnType}",
"all_relationships" : "http://localhost:7474/db/data/node/18/relationships/all",
"all_typed_relationships" : "http://localhost:7474/db/data/node/18/relationships/all/{-list|&|types}",
"property" : "http://localhost:7474/db/data/node/18/properties/{key}",
"self" : "http://localhost:7474/db/data/node/18",
"incoming_relationships" : "http://localhost:7474/db/data/node/18/relationships/in",
"properties" : "http://localhost:7474/db/data/node/18/properties",
"incoming_typed_relationships" : "http://localhost:7474/db/data/node/18/relationships/in/{-list|&|types}",
"data" : { }
}
Create node with properties
Example request
-
POSThttp://localhost:7474/db/data/node -
Accept:application/json; charset=UTF-8 -
Content-Type:application/json
{
"foo" : "bar"
}
Example response
-
201:Created -
Content-Length:1223 -
Content-Type:application/json; charset=UTF-8 -
Location:http://localhost:7474/db/data/node/14
{
"extensions" : { },
"metadata" : {
"id" : 14,
"labels" : [ ]
},
"paged_traverse" : "http://localhost:7474/db/data/node/14/paged/traverse/{returnType}{?pageSize,leaseTime}",
"outgoing_relationships" : "http://localhost:7474/db/data/node/14/relationships/out",
"outgoing_typed_relationships" : "http://localhost:7474/db/data/node/14/relationships/out/{-list|&|types}",
"create_relationship" : "http://localhost:7474/db/data/node/14/relationships",
"labels" : "http://localhost:7474/db/data/node/14/labels",
"traverse" : "http://localhost:7474/db/data/node/14/traverse/{returnType}",
"all_relationships" : "http://localhost:7474/db/data/node/14/relationships/all",
"all_typed_relationships" : "http://localhost:7474/db/data/node/14/relationships/all/{-list|&|types}",
"property" : "http://localhost:7474/db/data/node/14/properties/{key}",
"self" : "http://localhost:7474/db/data/node/14",
"incoming_relationships" : "http://localhost:7474/db/data/node/14/relationships/in",
"properties" : "http://localhost:7474/db/data/node/14/properties",
"incoming_typed_relationships" : "http://localhost:7474/db/data/node/14/relationships/in/{-list|&|types}",
"data" : {
"foo" : "bar"
}
}
Get node
Note that the response contains URI/templates for the available operations for getting properties and relationships.
Example request
-
GEThttp://localhost:7474/db/data/node/9 -
Accept:application/json; charset=UTF-8
Example response
-
200:OK -
Content-Type:application/json; charset=UTF-8
{
"extensions" : { },
"metadata" : {
"id" : 9,
"labels" : [ ]
},
"paged_traverse" : "http://localhost:7474/db/data/node/9/paged/traverse/{returnType}{?pageSize,leaseTime}",
"outgoing_relationships" : "http://localhost:7474/db/data/node/9/relationships/out",
"outgoing_typed_relationships" : "http://localhost:7474/db/data/node/9/relationships/out/{-list|&|types}",
"create_relationship" : "http://localhost:7474/db/data/node/9/relationships",
"labels" : "http://localhost:7474/db/data/node/9/labels",
"traverse" : "http://localhost:7474/db/data/node/9/traverse/{returnType}",
"all_relationships" : "http://localhost:7474/db/data/node/9/relationships/all",
"all_typed_relationships" : "http://localhost:7474/db/data/node/9/relationships/all/{-list|&|types}",
"property" : "http://localhost:7474/db/data/node/9/properties/{key}",
"self" : "http://localhost:7474/db/data/node/9",
"incoming_relationships" : "http://localhost:7474/db/data/node/9/relationships/in",
"properties" : "http://localhost:7474/db/data/node/9/properties",
"incoming_typed_relationships" : "http://localhost:7474/db/data/node/9/relationships/in/{-list|&|types}",
"data" : { }
}
Get non-existent node
Example request
-
GEThttp://localhost:7474/db/data/node/1300000 -
Accept:application/json; charset=UTF-8
Example response
-
404:Not Found -
Content-Type:application/json; charset=UTF-8
{
"message": "Cannot find node with id [1300000] in database.",
"exception": "NodeNotFoundException",
"fullname": "org.neo4j.server.rest.web.NodeNotFoundException",
"stackTrace": [
"org.neo4j.server.rest.web.DatabaseActions.node(DatabaseActions.java:165)",
"org.neo4j.server.rest.web.DatabaseActions.getNode(DatabaseActions.java:210)",
"org.neo4j.server.rest.web.RestfulGraphDatabase.getNode(RestfulGraphDatabase.java:279)",
"java.lang.reflect.Method.invoke(Method.java:497)",
"org.neo4j.server.rest.transactional.TransactionalRequestDispatcher.dispatch(TransactionalRequestDispatcher.java:145)",
"org.neo4j.server.rest.dbms.AuthorizationDisabledFilter.doFilter(AuthorizationDisabledFilter.java:48)",
"org.neo4j.server.rest.web.CollectUserAgentFilter.doFilter(CollectUserAgentFilter.java:69)",
"java.lang.Thread.run(Thread.java:745)"
],
"cause": {
"exception": "NotFoundException",
"cause": {
"exception": "EntityNotFoundException",
"fullname": "org.neo4j.kernel.api.exceptions.EntityNotFoundException",
"stackTrace": [
"org.neo4j.kernel.impl.factory.GraphDatabaseFacade.getNodeById(GraphDatabaseFacade.java:279)",
"org.neo4j.server.rest.web.DatabaseActions.node(DatabaseActions.java:161)",
"org.neo4j.server.rest.web.DatabaseActions.getNode(DatabaseActions.java:210)",
"org.neo4j.server.rest.web.RestfulGraphDatabase.getNode(RestfulGraphDatabase.java:279)",
"java.lang.reflect.Method.invoke(Method.java:497)",
"org.neo4j.server.rest.transactional.TransactionalRequestDispatcher.dispatch(TransactionalRequestDispatcher.java:145)",
"org.neo4j.server.rest.dbms.AuthorizationDisabledFilter.doFilter(AuthorizationDisabledFilter.java:48)",
"org.neo4j.server.rest.web.CollectUserAgentFilter.doFilter(CollectUserAgentFilter.java:69)",
"java.lang.Thread.run(Thread.java:745)"
],
"message": "Unable to load NODE with id 1300000.",
"errors": [
{
"code": "Neo.ClientError.Statement.EntityNotFound",
"message": "Unable to load NODE with id 1300000."
}
]
},
"fullname": "org.neo4j.graphdb.NotFoundException",
"stackTrace": [
"org.neo4j.kernel.impl.factory.GraphDatabaseFacade.getNodeById(GraphDatabaseFacade.java:279)",
"org.neo4j.server.rest.web.DatabaseActions.node(DatabaseActions.java:161)",
"org.neo4j.server.rest.web.DatabaseActions.getNode(DatabaseActions.java:210)",
"org.neo4j.server.rest.web.RestfulGraphDatabase.getNode(RestfulGraphDatabase.java:279)",
"java.lang.reflect.Method.invoke(Method.java:497)",
"org.neo4j.server.rest.transactional.TransactionalRequestDispatcher.dispatch(TransactionalRequestDispatcher.java:145)",
"org.neo4j.server.rest.dbms.AuthorizationDisabledFilter.doFilter(AuthorizationDisabledFilter.java:48)",
"org.neo4j.server.rest.web.CollectUserAgentFilter.doFilter(CollectUserAgentFilter.java:69)",
"java.lang.Thread.run(Thread.java:745)"
],
"message": "Node 1300000 not found",
"errors": [
{
"code": "Neo.ClientError.Statement.EntityNotFound",
"message": "Node 1300000 not found"
}
]
},
"errors": [
{
"code": "Neo.ClientError.Statement.EntityNotFound",
"message": "Cannot find node with id [1300000] in database."
}
]
}
Delete node
Example request
-
DELETEhttp://localhost:7474/db/data/node/15 -
Accept:application/json; charset=UTF-8
Example response
-
204:No Content
Nodes with relationships cannot be deleted
The relationships on a node has to be deleted before the node can be deleted.
| Tip You can use |
Example request
-
DELETEhttp://localhost:7474/db/data/node/22 -
Accept:application/json; charset=UTF-8
Example response
-
409:Conflict -
Content-Type:application/json; charset=UTF-8
{
"message": "The node with id 22 cannot be deleted. Check that the node is orphaned before deletion.",
"exception": "ConstraintViolationException",
"fullname": "org.neo4j.graphdb.ConstraintViolationException",
"stackTrace": [
"org.neo4j.server.rest.web.DatabaseActions.deleteNode(DatabaseActions.java:220)",
"org.neo4j.server.rest.web.RestfulGraphDatabase.deleteNode(RestfulGraphDatabase.java:293)",
"java.lang.reflect.Method.invoke(Method.java:497)",
"org.neo4j.server.rest.transactional.TransactionalRequestDispatcher.dispatch(TransactionalRequestDispatcher.java:145)",
"org.neo4j.server.rest.dbms.AuthorizationDisabledFilter.doFilter(AuthorizationDisabledFilter.java:48)",
"org.neo4j.server.rest.web.CollectUserAgentFilter.doFilter(CollectUserAgentFilter.java:69)",
"java.lang.Thread.run(Thread.java:745)"
],
"errors": [
{
"code": "Neo.ClientError.Schema.ConstraintValidationFailed",
"message": "The node with id 22 cannot be deleted. Check that the node is orphaned before deletion."
}
]
}