0
votes

I try to send a simple Cypher query to neo4j 2.1.3 and get a 500 response:

POST : http://localhost:7474/db/data/cypher

data = {
  "query" : "MATCH (it) return it limit 10"
   }

Tried different variations of including the following header:

   {'content-type': 'application/json',"Accept": 'application/json'}

All resulted in the same 500 http response.

Btw .. Regular Rest API requests such as : http://localhost:7474/db/data/node works just fine..

2
can you share the exact code you used to send that http request? - Michael Hunger
also can you check the data/log/neo4j.log file for an error message? - Michael Hunger
there is no code... I just tried a POST request using 'postman' . and there are no traces of it in the logs - skme

2 Answers

0
votes

Not 100% but AFAIK http headers are case sensitive, so try to use Content-Type instead of content-type. If you still get a 500, inspect data/log and/or data/graph.db/messages.log for any helpful entries.

0
votes

Apparently the problem was in the encoding of the data. Not sure exactly what, but I found it in neo4j-rest-client code .

There is an encoding function. Used that and everything works.

def _json_encode( data, ensure_ascii=False):

 def _any(data):
    ret = None
    if isinstance(data, (list, tuple)):
        ret = _list(data)
    elif isinstance(data, dict):
        ret = _dict(data)
    elif isinstance(data, decimal.Decimal):
        ret = str(data)
    elif isinstance(data, datetime.time):
        ret = data.strftime(options.TIME_FORMAT)
    else:
        ret = data
    return ret

 def _list(data):
    ret = []
    for v in data:
        ret.append(_any(v))
    return ret

 def _dict(data):
    ret = {}
    for k, v in data.items():
        # Neo4j doesn't allow 'null' properties
        if v is not None:
            ret[k] = _any(v)
    return ret
 ret = _any(data)
 return json.dumps(ret, ensure_ascii=ensure_ascii)