Prev |  | Next

## 18.4. Nodes

### 18.4.1. Create Node

Figure 18.8. Final Graph

Example request

- `POST` `http://localhost:7474/db/data/node`
- `Accept:` `application/json`

Example response

- `201:` `Created`
- `Content-Type:` `application/json`
- `Location:` `http://localhost:7474/db/data/node/1`

    {
      "extensions" : {
      },
      "paged_traverse" : "http://localhost:7474/db/data/node/1/paged/traverse/{returnType}{?pageSize,leaseTime}",
      "outgoing_relationships" : "http://localhost:7474/db/data/node/1/relationships/out",
      "traverse" : "http://localhost:7474/db/data/node/1/traverse/{returnType}",
      "all_typed_relationships" : "http://localhost:7474/db/data/node/1/relationships/all/{-list|&|types}",
      "property" : "http://localhost:7474/db/data/node/1/properties/{key}",
      "all_relationships" : "http://localhost:7474/db/data/node/1/relationships/all",
      "self" : "http://localhost:7474/db/data/node/1",
      "properties" : "http://localhost:7474/db/data/node/1/properties",
      "outgoing_typed_relationships" : "http://localhost:7474/db/data/node/1/relationships/out/{-list|&|types}",
      "incoming_relationships" : "http://localhost:7474/db/data/node/1/relationships/in",
      "incoming_typed_relationships" : "http://localhost:7474/db/data/node/1/relationships/in/{-list|&|types}",
      "create_relationship" : "http://localhost:7474/db/data/node/1/relationships",
      "data" : {
      }
    }

### 18.4.2. Create Node with properties

Figure 18.9. Final Graph

Example request

- `POST` `http://localhost:7474/db/data/node`
- `Accept:` `application/json`
- `Content-Type:` `application/json`

    {
      "foo" : "bar"
    }

Example response

- `201:` `Created`
- `Content-Length:` `1096`
- `Content-Type:` `application/json`
- `Location:` `http://localhost:7474/db/data/node/2`

    {
      "extensions" : {
      },
      "paged_traverse" : "http://localhost:7474/db/data/node/2/paged/traverse/{returnType}{?pageSize,leaseTime}",
      "outgoing_relationships" : "http://localhost:7474/db/data/node/2/relationships/out",
      "traverse" : "http://localhost:7474/db/data/node/2/traverse/{returnType}",
      "all_typed_relationships" : "http://localhost:7474/db/data/node/2/relationships/all/{-list|&|types}",
      "property" : "http://localhost:7474/db/data/node/2/properties/{key}",
      "all_relationships" : "http://localhost:7474/db/data/node/2/relationships/all",
      "self" : "http://localhost:7474/db/data/node/2",
      "properties" : "http://localhost:7474/db/data/node/2/properties",
      "outgoing_typed_relationships" : "http://localhost:7474/db/data/node/2/relationships/out/{-list|&|types}",
      "incoming_relationships" : "http://localhost:7474/db/data/node/2/relationships/in",
      "incoming_typed_relationships" : "http://localhost:7474/db/data/node/2/relationships/in/{-list|&|types}",
      "create_relationship" : "http://localhost:7474/db/data/node/2/relationships",
      "data" : {
        "foo" : "bar"
      }
    }

### 18.4.3. Get node

Note that the response contains URI/templates for the available operations for getting properties and relationships.

Figure 18.10. Final Graph

Example request

- `GET` `http://localhost:7474/db/data/node/3`
- `Accept:` `application/json`

Example response

- `200:` `OK`
- `Content-Type:` `application/json`

    {
      "extensions" : {
      },
      "paged_traverse" : "http://localhost:7474/db/data/node/3/paged/traverse/{returnType}{?pageSize,leaseTime}",
      "outgoing_relationships" : "http://localhost:7474/db/data/node/3/relationships/out",
      "traverse" : "http://localhost:7474/db/data/node/3/traverse/{returnType}",
      "all_typed_relationships" : "http://localhost:7474/db/data/node/3/relationships/all/{-list|&|types}",
      "property" : "http://localhost:7474/db/data/node/3/properties/{key}",
      "all_relationships" : "http://localhost:7474/db/data/node/3/relationships/all",
      "self" : "http://localhost:7474/db/data/node/3",
      "properties" : "http://localhost:7474/db/data/node/3/properties",
      "outgoing_typed_relationships" : "http://localhost:7474/db/data/node/3/relationships/out/{-list|&|types}",
      "incoming_relationships" : "http://localhost:7474/db/data/node/3/relationships/in",
      "incoming_typed_relationships" : "http://localhost:7474/db/data/node/3/relationships/in/{-list|&|types}",
      "create_relationship" : "http://localhost:7474/db/data/node/3/relationships",
      "data" : {
      }
    }

### 18.4.4. Get non-existent node

Figure 18.11. Final Graph

Example request

- `GET` `http://localhost:7474/db/data/node/800000`
- `Accept:` `application/json`

Example response

- `404:` `Not Found`
- `Content-Type:` `application/json`

    {
      "message" : "Cannot find node with id [800000] in database.",
      "exception" : "NodeNotFoundException",
      "stacktrace" : [ "org.neo4j.server.rest.web.DatabaseActions.node(DatabaseActions.java:123)", "org.neo4j.server.rest.web.DatabaseActions.getNode(DatabaseActions.java:234)", "org.neo4j.server.rest.web.RestfulGraphDatabase.getNode(RestfulGraphDatabase.java:225)", "java.lang.reflect.Method.invoke(Method.java:597)" ]
    }

### 18.4.5. Delete node

Figure 18.12. Final Graph

Example request

- `DELETE` `http://localhost:7474/db/data/node/10`
- `Accept:` `application/json`

Example response

- `204:` `No Content`

### 18.4.6. Nodes with relationships can not be deleted

The relationships on a node has to be deleted before the node can be deleted.

Figure 18.13. Final Graph

Example request

- `DELETE` `http://localhost:7474/db/data/node/11`
- `Accept:` `application/json`

Example response

- `409:` `Conflict`
- `Content-Type:` `application/json`

    {
      "message" : "The node with id 11 cannot be deleted. Check that the node is orphaned before deletion.",
      "exception" : "OperationFailureException",
      "stacktrace" : [ "org.neo4j.server.rest.web.DatabaseActions.deleteNode(DatabaseActions.java:255)", "org.neo4j.server.rest.web.RestfulGraphDatabase.deleteNode(RestfulGraphDatabase.java:239)", "java.lang.reflect.Method.invoke(Method.java:597)" ]
    }

Copyright © 2013 Neo Technology

Prev | Up | Next
| Home |