【问题标题】:Neo4j REST API - create unique nodeNeo4j REST API - 创建唯一节点
【发布时间】:2013-04-28 20:40:36
【问题描述】:

我正在尝试使用 REST API 创建一个唯一节点。但是,我收到有关需要密钥“uri”的错误(见下文)。根据记录的示例,此调用创建并索引新创建的节点......所以不应该有“uri”参数。我的要求和回应如下。我做错了什么?

请求:

http://www.somemachine.com:7474/db/data/index/node/idxHost?unique=get_or_create

{
    "key": "name",
    "value": "HOST",
    "properties": {
        "type": "company",
        "name": "HOST",
        "sequence": 1
    }
}

回复:

状态:400,正文:

{
  "message" : "Missing required key: \"uri\"",
  "exception" : "BadInputException",
  "fullname" : "org.neo4j.server.rest.repr.BadInputException",
  "stacktrace" : [ "org.neo4j.server.rest.repr.formats.JsonFormat.readMap(JsonFormat.java:92)", "org.neo4j.server.rest.web.RestfulGraphDatabase.addToNodeIndex(RestfulGraphDatabase.java:802)", "java.lang.reflect.Method.invoke(Method.java:601)" ],
  "cause" : {
    "message" : "Missing required key: \"uri\"",
    "exception" : "BadInputException",
    "stacktrace" : [ "org.neo4j.server.rest.repr.DefaultFormat.validateKeys(DefaultFormat.java:153)", "org.neo4j.server.rest.repr.formats.JsonFormat.readMap(JsonFormat.java:88)", "org.neo4j.server.rest.web.RestfulGraphDatabase.addToNodeIndex(RestfulGraphDatabase.java:802)", "java.lang.reflect.Method.invoke(Method.java:601)" ],
    "fullname" : "org.neo4j.server.rest.repr.BadInputException"
  }
}

使用卷曲 c:\apps\curl\curl-7.28.1-win64-nossl>curl -i -H "接受:应用程序/json" -H "内容类型:应用程序/json" -X POST -d '{"key" :"name","value":"HOST","proper ies":{"type":"company","name":"HOST","sequence":1}}' http://www.somemachine.com:7474/db/data/index/node/idxHost?unique=get_or_create HTTP/1.1 400 错误请求 内容长度:489 内容编码:UTF-8 内容类型:应用程序/json 访问控制允许来源:* 服务器:码头(6.1.25)

{ “消息”:“意外字符('''(代码 39)):在 [Source: java.lang. io.Str ingReader@1e70f68;行:1,列:2]", “异常”:“BadInputException”, “堆栈跟踪”:[“org.neo4j.server.rest.repr.formats.JsonFormat.readMap(JsonFormat.java:92)”,“org.neo4j.server.rest.web.RestfulGraphDatabase.addToNodeIndex(R estfulGraphDatabase.java:776)", "java.lang.reflect.Method.invoke(Unknown Source)"] }

【问题讨论】:

  • 您使用的是哪个版本的neo4j
  • 它可能来自您正在使用的库(如果有)错误地格式化您的请求。你试过 curl 吗?

标签: rest neo4j


【解决方案1】:

根据文档,在 1.8 中,url 以 '?unique' 结尾,而在 1.9 中是 '?uniqueness=get_or_create'

我认为这可能会导致您的错误。

查看 1.8:http://docs.neo4j.org/chunked/stable/rest-api-unique-indexes.html#rest-api-add-a-node-to-an-index-unless-a-node-already-exists-for-the-given-mapping

和 1.9:http://docs.neo4j.org/chunked/milestone/rest-api-unique-indexes.html

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-08-24
    • 1970-01-01
    • 2023-03-22
    相关资源
    最近更新 更多