20.11. Node properties

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 20.37. Final Graph

Example request

  • PUT http://localhost:7474/db/data/node/52/properties/foo
  • Accept: application/json; charset=UTF-8
  • Content-Type: application/json
"bar"

Example response

  • 204: No Content

Update node properties

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

Figure 20.38. Final Graph

Example request

  • PUT http://localhost:7474/db/data/node/51/properties
  • Accept: application/json; charset=UTF-8
  • Content-Type: application/json
{
  "age" : "18"
}

Example response

  • 204: No Content

Get properties for node

Figure 20.39. Final Graph

Example request

  • GET http://localhost:7474/db/data/node/136/properties
  • Accept: application/json; charset=UTF-8

Example response

  • 200: OK
  • Content-Type: application/json; charset=UTF-8
{
  "foo" : "bar"
}

Get property for node

Get a single node property from a node.

Figure 20.40. Final Graph

Example request

  • GET http://localhost:7474/db/data/node/135/properties/foo
  • Accept: application/json; charset=UTF-8

Example response

  • 200: OK
  • Content-Type: application/json; charset=UTF-8
"bar"

Property values can not be null

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

Example request

  • POST http://localhost:7474/db/data/node
  • Accept: application/json; charset=UTF-8
  • Content-Type: application/json
{
  "foo" : null
}

Example response

  • 400: Bad Request
  • Content-Type: application/json; charset=UTF-8
{
  "message": "Could not set property \"foo\", unsupported type: null",
  "exception": "PropertyValueException",
  "fullname": "org.neo4j.server.rest.web.PropertyValueException",
  "stackTrace": [
    "org.neo4j.server.rest.domain.PropertySettingStrategy.setProperty(PropertySettingStrategy.java:141)",
    "org.neo4j.server.rest.domain.PropertySettingStrategy.setProperties(PropertySettingStrategy.java:88)",
    "org.neo4j.server.rest.web.DatabaseActions.createNode(DatabaseActions.java:196)",
    "org.neo4j.server.rest.web.RestfulGraphDatabase.createNode(RestfulGraphDatabase.java:252)",
    "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.Statement.ArgumentError",
      "message": "Could not set property \"foo\", unsupported type: null"
    }
  ]
}

Property values can not be nested

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

Example request

  • POST http://localhost:7474/db/data/node/
  • Accept: application/json; charset=UTF-8
  • Content-Type: application/json
{
  "foo" : {
    "bar" : "baz"
  }
}

Example response

  • 400: Bad Request
  • Content-Type: application/json; charset=UTF-8
{
  "message": "Could not set property \"foo\", unsupported type: {bar\u003dbaz}",
  "exception": "PropertyValueException",
  "fullname": "org.neo4j.server.rest.web.PropertyValueException",
  "stackTrace": [
    "org.neo4j.server.rest.domain.PropertySettingStrategy.setProperty(PropertySettingStrategy.java:141)",
    "org.neo4j.server.rest.domain.PropertySettingStrategy.setProperties(PropertySettingStrategy.java:88)",
    "org.neo4j.server.rest.web.DatabaseActions.createNode(DatabaseActions.java:196)",
    "org.neo4j.server.rest.web.RestfulGraphDatabase.createNode(RestfulGraphDatabase.java:252)",
    "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.Statement.ArgumentError",
      "message": "Could not set property \"foo\", unsupported type: {bar\u003dbaz}"
    }
  ]
}

Delete all properties from node

Figure 20.41. Starting Graph

Figure 20.42. Final Graph

Example request

  • DELETE http://localhost:7474/db/data/node/51/properties
  • Accept: application/json; charset=UTF-8

Example response

  • 204: No Content

Delete a named property from a node

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

Figure 20.43. Starting Graph

Figure 20.44. Final Graph

Example request

  • DELETE http://localhost:7474/db/data/node/50/properties/name
  • Accept: application/json; charset=UTF-8

Example response

  • 204: No Content