21.12. Relationship properties

Update relationship properties

Figure 21.43. Final Graph

Example request

  • PUT http://localhost:7474/db/data/relationship/60/properties
  • Accept: application/json; charset=UTF-8
  • Content-Type: application/json
{
  "jim" : "tobias"
}

Example response

  • 204: No Content

Remove properties from a relationship

Figure 21.44. Final Graph

Example request

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

Example response

  • 204: No Content

Remove property from a relationship

See the example request below.

Figure 21.45. Starting Graph

Figure 21.46. Final Graph

Example request

  • DELETE http://localhost:7474/db/data/relationship/7/properties/cost
  • Accept: application/json; charset=UTF-8

Example response

  • 204: No Content

Remove non-existent property from a relationship

Attempting to remove a property that doesn’t exist results in an error.

Figure 21.47. Final Graph

Example request

  • DELETE http://localhost:7474/db/data/relationship/5/properties/non-existent
  • Accept: application/json; charset=UTF-8

Example response

  • 404: Not Found
  • Content-Type: application/json; charset=UTF-8
{
  "message": "Relationship[5] does not have a property \"non-existent\"",
  "exception": "NoSuchPropertyException",
  "fullname": "org.neo4j.server.rest.web.NoSuchPropertyException",
  "stackTrace": [
    "org.neo4j.server.rest.web.DatabaseActions.removeRelationshipProperty(DatabaseActions.java:672)",
    "org.neo4j.server.rest.web.RestfulGraphDatabase.deleteRelationshipProperty(RestfulGraphDatabase.java:801)",
    "java.lang.reflect.Method.invoke(Method.java:606)",
    "org.neo4j.server.rest.transactional.TransactionalRequestDispatcher.dispatch(TransactionalRequestDispatcher.java:139)",
    "java.lang.Thread.run(Thread.java:745)"
  ],
  "errors": [
    {
      "message": "Relationship[5] does not have a property \"non-existent\"",
      "code": "Neo.ClientError.Statement.NoSuchProperty"
    }
  ]
}

Remove properties from a non-existing relationship

Attempting to remove all properties from a relationship which doesn’t exist results in an error.

Figure 21.48. Final Graph

Example request

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

Example response

  • 404: Not Found
  • Content-Type: application/json; charset=UTF-8
{
  "message": "org.neo4j.graphdb.NotFoundException: Relationship 1234 not found",
  "exception": "RelationshipNotFoundException",
  "fullname": "org.neo4j.server.rest.web.RelationshipNotFoundException",
  "stackTrace": [
    "org.neo4j.server.rest.web.DatabaseActions.relationship(DatabaseActions.java:190)",
    "org.neo4j.server.rest.web.DatabaseActions.removeAllRelationshipProperties(DatabaseActions.java:662)",
    "org.neo4j.server.rest.web.RestfulGraphDatabase.deleteAllRelationshipProperties(RestfulGraphDatabase.java:781)",
    "java.lang.reflect.Method.invoke(Method.java:606)",
    "org.neo4j.server.rest.transactional.TransactionalRequestDispatcher.dispatch(TransactionalRequestDispatcher.java:139)",
    "java.lang.Thread.run(Thread.java:745)"
  ],
  "cause": {
    "message": "Relationship 1234 not found",
    "errors": [
      {
        "message": "Relationship 1234 not found",
        "code": "Neo.ClientError.Statement.EntityNotFound"
      }
    ],
    "cause": {
      "message": "Unable to load RELATIONSHIP with id 1234.",
      "errors": [
        {
          "message": "Unable to load RELATIONSHIP with id 1234.",
          "code": "Neo.ClientError.Statement.EntityNotFound"
        }
      ],
      "exception": "EntityNotFoundException",
      "fullname": "org.neo4j.kernel.api.exceptions.EntityNotFoundException",
      "stackTrace": [
        "org.neo4j.kernel.InternalAbstractGraphDatabase.getRelationshipById(InternalAbstractGraphDatabase.java:1099)",
        "org.neo4j.server.rest.web.DatabaseActions.relationship(DatabaseActions.java:186)",
        "org.neo4j.server.rest.web.DatabaseActions.removeAllRelationshipProperties(DatabaseActions.java:662)",
        "org.neo4j.server.rest.web.RestfulGraphDatabase.deleteAllRelationshipProperties(RestfulGraphDatabase.java:781)",
        "java.lang.reflect.Method.invoke(Method.java:606)",
        "org.neo4j.server.rest.transactional.TransactionalRequestDispatcher.dispatch(TransactionalRequestDispatcher.java:139)",
        "java.lang.Thread.run(Thread.java:745)"
      ]
    },
    "exception": "NotFoundException",
    "fullname": "org.neo4j.graphdb.NotFoundException",
    "stackTrace": [
      "org.neo4j.kernel.InternalAbstractGraphDatabase.getRelationshipById(InternalAbstractGraphDatabase.java:1099)",
      "org.neo4j.server.rest.web.DatabaseActions.relationship(DatabaseActions.java:186)",
      "org.neo4j.server.rest.web.DatabaseActions.removeAllRelationshipProperties(DatabaseActions.java:662)",
      "org.neo4j.server.rest.web.RestfulGraphDatabase.deleteAllRelationshipProperties(RestfulGraphDatabase.java:781)",
      "java.lang.reflect.Method.invoke(Method.java:606)",
      "org.neo4j.server.rest.transactional.TransactionalRequestDispatcher.dispatch(TransactionalRequestDispatcher.java:139)",
      "java.lang.Thread.run(Thread.java:745)"
    ]
  },
  "errors": [
    {
      "message": "org.neo4j.graphdb.NotFoundException: Relationship 1234 not found",
      "code": "Neo.ClientError.Statement.EntityNotFound"
    }
  ]
}

Remove property from a non-existing relationship

Attempting to remove a property from a relationship which doesn’t exist results in an error.

Figure 21.49. Final Graph

Example request

  • DELETE http://localhost:7474/db/data/relationship/1234/properties/cost
  • Accept: application/json; charset=UTF-8

Example response

  • 404: Not Found
  • Content-Type: application/json; charset=UTF-8
{
  "message": "org.neo4j.graphdb.NotFoundException: Relationship 1234 not found",
  "exception": "RelationshipNotFoundException",
  "fullname": "org.neo4j.server.rest.web.RelationshipNotFoundException",
  "stackTrace": [
    "org.neo4j.server.rest.web.DatabaseActions.relationship(DatabaseActions.java:190)",
    "org.neo4j.server.rest.web.DatabaseActions.removeRelationshipProperty(DatabaseActions.java:668)",
    "org.neo4j.server.rest.web.RestfulGraphDatabase.deleteRelationshipProperty(RestfulGraphDatabase.java:801)",
    "java.lang.reflect.Method.invoke(Method.java:606)",
    "org.neo4j.server.rest.transactional.TransactionalRequestDispatcher.dispatch(TransactionalRequestDispatcher.java:139)",
    "java.lang.Thread.run(Thread.java:745)"
  ],
  "cause": {
    "message": "Relationship 1234 not found",
    "errors": [
      {
        "message": "Relationship 1234 not found",
        "code": "Neo.ClientError.Statement.EntityNotFound"
      }
    ],
    "cause": {
      "message": "Unable to load RELATIONSHIP with id 1234.",
      "errors": [
        {
          "message": "Unable to load RELATIONSHIP with id 1234.",
          "code": "Neo.ClientError.Statement.EntityNotFound"
        }
      ],
      "exception": "EntityNotFoundException",
      "fullname": "org.neo4j.kernel.api.exceptions.EntityNotFoundException",
      "stackTrace": [
        "org.neo4j.kernel.InternalAbstractGraphDatabase.getRelationshipById(InternalAbstractGraphDatabase.java:1099)",
        "org.neo4j.server.rest.web.DatabaseActions.relationship(DatabaseActions.java:186)",
        "org.neo4j.server.rest.web.DatabaseActions.removeRelationshipProperty(DatabaseActions.java:668)",
        "org.neo4j.server.rest.web.RestfulGraphDatabase.deleteRelationshipProperty(RestfulGraphDatabase.java:801)",
        "java.lang.reflect.Method.invoke(Method.java:606)",
        "org.neo4j.server.rest.transactional.TransactionalRequestDispatcher.dispatch(TransactionalRequestDispatcher.java:139)",
        "java.lang.Thread.run(Thread.java:745)"
      ]
    },
    "exception": "NotFoundException",
    "fullname": "org.neo4j.graphdb.NotFoundException",
    "stackTrace": [
      "org.neo4j.kernel.InternalAbstractGraphDatabase.getRelationshipById(InternalAbstractGraphDatabase.java:1099)",
      "org.neo4j.server.rest.web.DatabaseActions.relationship(DatabaseActions.java:186)",
      "org.neo4j.server.rest.web.DatabaseActions.removeRelationshipProperty(DatabaseActions.java:668)",
      "org.neo4j.server.rest.web.RestfulGraphDatabase.deleteRelationshipProperty(RestfulGraphDatabase.java:801)",
      "java.lang.reflect.Method.invoke(Method.java:606)",
      "org.neo4j.server.rest.transactional.TransactionalRequestDispatcher.dispatch(TransactionalRequestDispatcher.java:139)",
      "java.lang.Thread.run(Thread.java:745)"
    ]
  },
  "errors": [
    {
      "message": "org.neo4j.graphdb.NotFoundException: Relationship 1234 not found",
      "code": "Neo.ClientError.Statement.EntityNotFound"
    }
  ]
}