[[rest-api-creating-a-relationship-to-a-nonexisting-end-node]]
=== Creating a relationship to a nonexisting end node ===

.Final Graph
["dot", "Final-Graph-creating-a-relationship-to-a-nonexisting-end-node.svg", "neoviz", ""]
----
  N90 [
    label = "{Node\[90\]|name = \'Sara\'\l}"
  ]
  N91 [
    label = "{Node\[91\]|name = \'Joe\'\l}"
  ]
  N91 -> N90 [
    color = "#2e3436"
    fontcolor = "#2e3436"
    label = "knows\n"
  ]
----

_Example request_

* *+POST+*  +http://localhost:7474/db/data/node/91/relationships+
* *+Accept:+* +application/json+
* *+Content-Type:+* +application/json+
[source,javascript]
----
{
  "to" : "http://localhost:7474/db/data/node/999999",
  "type" : "LOVES",
  "data" : {
    "foo" : "bar"
  }
}
----


_Example response_

* *+400:+* +Bad Request+
* *+Content-Type:+* +application/json+
[source,javascript]
----
{
  "exception" : "EndNodeNotFoundException",
  "stacktrace" : [ "org.neo4j.server.rest.web.DatabaseActions.createRelationship(DatabaseActions.java:577)", "org.neo4j.server.rest.web.RestfulGraphDatabase.createRelationship(RestfulGraphDatabase.java:406)", "java.lang.reflect.Method.invoke(Method.java:597)" ]
}
----


