Prev |  | Next

## 18.7. Node properties

### 18.7.1. Set property on node

Setting different properties will retain the existing ones for this node. Note that a single value are submitted not as a map but just as a value (which is valid JSON) like in the example below.

Figure 18.32. Final Graph

Example request

- `PUT` `http://localhost:7474/db/data/node/17/properties/foo`
- `Accept:` `application/json`
- `Content-Type:` `application/json`

    "bar"

Example response

- `204:` `No Content`

### 18.7.2. Update node properties

This will replace all existing properties on the node with the new set of attributes.

Figure 18.33. Final Graph

Example request

- `PUT` `http://localhost:7474/db/data/node/9/properties`
- `Accept:` `application/json`
- `Content-Type:` `application/json`

    {
      "age" : "18"
    }

Example response

- `204:` `No Content`

### 18.7.3. Get properties for node

Figure 18.34. Final Graph

Example request

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

Example response

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

    {
      "foo" : "bar"
    }

### 18.7.4. Property values can not be null

This example shows the response you get when trying to set a property to `null`.

Figure 18.35. Final Graph

Example request

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

    {
      "foo" : null
    }

Example response

- `400:` `Bad Request`
- `Content-Type:` `application/json`

    {
      "message" : "Could not set property \"foo\", unsupported type: null",
      "exception" : "PropertyValueException",
      "stacktrace" : [ "org.neo4j.server.rest.web.DatabaseActions.set(DatabaseActions.java:155)", "org.neo4j.server.rest.web.DatabaseActions.createNode(DatabaseActions.java:213)", "org.neo4j.server.rest.web.RestfulGraphDatabase.createNode(RestfulGraphDatabase.java:195)", "java.lang.reflect.Method.invoke(Method.java:597)" ]
    }

### 18.7.5. Property values can not be nested

Nesting properties is not supported. You could for example store the nested JSON as a string instead.

Figure 18.36. Final Graph

Example request

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

    {
      "foo" : {
        "bar" : "baz"
      }
    }

Example response

- `400:` `Bad Request`
- `Content-Type:` `application/json`

    {
      "message" : "Could not set property \"foo\", unsupported type: {bar=baz}",
      "exception" : "PropertyValueException",
      "stacktrace" : [ "org.neo4j.server.rest.web.DatabaseActions.set(DatabaseActions.java:155)", "org.neo4j.server.rest.web.DatabaseActions.createNode(DatabaseActions.java:213)", "org.neo4j.server.rest.web.RestfulGraphDatabase.createNode(RestfulGraphDatabase.java:195)", "java.lang.reflect.Method.invoke(Method.java:597)" ]
    }

### 18.7.6. Delete all properties from node

Figure 18.37. Final Graph

Example request

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

Example response

- `204:` `No Content`

### 18.7.7. Delete a named property from a node

To delete a single property from a node, see the example below.

Figure 18.38. Starting Graph

Figure 18.39. Final Graph

Example request

- `DELETE` `http://localhost:7474/db/data/node/28/properties/name`
- `Accept:` `application/json`

Example response

- `204:` `No Content`

Copyright © 2012 Neo Technology

Prev | Up | Next
| Home |