带有CYPHER请求的API REST

时间:2015-01-08 21:11:01

标签: curl neo4j

执行此命令时:

curl -X POST

 -H "Content-Type:application/json" 

 -d '{\"statements\" : [ 

 {\"statement\" : \"MATCH n OPTIONAL MATCH n-[r]-m

   DELETE n,r\"} ]}' 

 http://localhost:7474/db/data/transaction/commit

我得到了这个结果:


curl: (7) couldn't connect to host
curl: (3) [globbing] illegal character in range specification at pos 2
curl: (7) couldn't connect to host
curl: (6) Couldn't resolve host '"MATCH'
curl: (6) Couldn't resolve host 'n'
curl: (6) Couldn't resolve host 'OPTIONAL'
curl: (6) Couldn't resolve host 'MATCH'
curl: (3) [globbing] error: bad range specification after pos 4
curl: (6) Couldn't resolve host 'DELETE'
curl: (3) [globbing] unmatched close brace/bracket at pos 5
curl: (3) [globbing] unmatched close brace/bracket at pos 1
{"results":[],"errors":[]}

为什么我会遇到这个问题?知道我有一个neo4j数据库...

3 个答案:

答案 0 :(得分:1)

您需要将整个事物放在一行上或在每行末尾使用反斜杠。有关cURL和Neo4j,请参阅my reply on a different question

答案 1 :(得分:0)

你可以这样试试:

    data='{
        "statements": [
            {
                "statement": "MATCH n OPTIONAL MATCH n-[r]-m DELETE n,r"
            }
        ]
      }'

curl -X POST 'http://localhost:7474/db/data/transaction/commit'  \
-H 'Content-Type: application/json' \
-d "$data"

答案 2 :(得分:0)

curl -X POST -H accept:application/json \
-H content-type:application/json \
-H Authorization:"Basic <your auth>" \
http://localhost:7474/db/data/transaction/commit \
-d "{\"statements\": [{\"statement\": \"MATCH n OPTIONAL MATCH n-[r]-m DELETE n,r\"}]}"

这个很好用;涵盖身份验证、查询和接受内容。