我正在尝试使用REST API来创建唯一节点。但是,我收到关于要求密钥'uri'的错误(请参阅下文)。根据记录的例子,这个调用创建并索引新创建的节点...所以不应该有'uri'参数。我的要求和回复如下。我究竟做错了什么?Neo4j REST API - 创建唯一节点
REQUEST:
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
}
}
RESPONSE:
状态: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“Accept:application/json”-H“Content-Type:application/json”-X POST -d '{“key”:“name”,“value”:“HOST”,“propert 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错误的请求 的Content-Length:489 内容编码:UTF-8 内容类型:应用/ JSON 访问控制允许来源:* 服务器:码头(6.1.25)
“message”:“意外字符('''(代码39)):预期有效值(数字,字符串,数组,对象,'true','false'或'null')\ n at [Source:java.io.Str ingReader @ 1e70f68;行:1,列:2]“, ”exception“:”BadInputException“, ”stacktrace“:[”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(未知来源)”] }
您正在使用哪个版本的'neo4j'? – Nicholas 2013-05-04 17:06:13
它可能来自您正在使用的库(如果有)严重格式化您的请求。你尝试过卷曲吗? – RaduK 2013-05-06 07:06:23
版本是1.8.2 – user2350063 2013-05-06 13:43:01