来自Meteor Server的HTTP Post不起作用 - 语法问题?

时间:2014-06-19 02:14:50

标签: meteor neo4j cypher

我正在尝试使用Meteor的HTTP.call POST方法,以便通过Neo4j REST事务点发出Cypher查询。但是,Cypher日志会给我错误。有关如何纠正可疑语法问题的建议将不胜感激:

HTTP.call('POST', 'http://localhost:7474/db/data/cypher',
    {headers:{"Accept": "application/json",
    "Content-Type": "application/json"},
    query: "MATCH (n:unit) RETURN n LIMIT 25"},
    function (error, result) {
    // callback function here, not shown for brevity...
});

这是Neo4j控制台中的典型错误消息:

" POST / db / data / cypher?MATCH%20(n:unit)%20RETURN%20n%20LIMIT%2025 HTTP / 1.1" 400 469" - " " - "

1 个答案:

答案 0 :(得分:1)

将Cypher查询写入content属性而不是query

HTTP.call('POST', 'http://localhost:7474/db/data/cypher',
  {headers:{"Accept": "application/json",
  "Content-Type": "application/json"},
  content: "MATCH (n:unit) RETURN n LIMIT 25"},
  function (error, result) {
  // callback function here, not shown for brevity...
});

实际上content(或数据)is for the request body,而查询是在GET请求中类似于URL的查询字符串。