neo4j-spatial

14 views
Skip to first unread message

Matthew Hodges

unread,
Dec 27, 2015, 4:42:38 PM12/27/15
to Node-Neo4j Discussion
Hi Aseem, Hi Node-Neo4j,

I'm trying to work neo4j-spatial using the db.http interface but getting an error.  My code:

var neo4j = require('neo4j');
neodb = new neo4j.GraphDatabase( {url: 'http://neo4j:pwd@localhost:7474'} );

var p = '/db/data/ext/SpatialPlugin/graphdb/addSimplePointLayer';
var h = 'Content-Type:application/json';
var b = {layer:'geom',lat:'lat',lon:'lon'};
var cb = function(err, body){ if (err){ throw err; }  console.log(body); }

//this works:  neodb.http({ method: 'GET', path: '/db/data/node/1234', body:{} }, cb);
neodb.http({ method:'POST', path:p, headers:h, body:b, raw:true }, cb)

The GET node works fine, but the POST to the SpatialPlugin fails somewhere in requestjs:

  Object.keys(obj).forEach(function (i) {
         ^
TypeError: Object.keys called on non-object
    at Function.keys (native)
    at copy (/home/hierozbosch/gcrt2neo/node_modules/neo4j/node_modules/request/lib/helpers.js:51:10)
    at Request.init (/home/hierozbosch/gcrt2neo/node_modules/neo4j/node_modules/request/request.js:162:33)
    at new Request (/home/hierozbosch/gcrt2neo/node_modules/neo4j/node_modules/request/request.js:140:8)
    at request (/home/hierozbosch/gcrt2neo/node_modules/neo4j/node_modules/request/index.js:55:10)
    at GraphDatabase.module.exports.GraphDatabase.http (/home/hierozbosch/gcrt2neo/node_modules/neo4j/lib-new/GraphDatabase.js:76:14)
    at Object.<anonymous> (/home/hierozbosch/gcrt2neo/spatial.js:10:7)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)

I've tested the neo4j-spatial part with curl and it works:

#!/bin/bash
curl -X POST -d '{"layer":"geom","lat":"lat","lon":"lon"}' --header "Content-Type:application/json" http://localhost:7474/db/data/ext/SpatialPlugin/graphdb/addSimplePointLayer

Has anyone done this?  Any ideas?

Thanks,
Matt Hodges

Aseem Kishore

unread,
Dec 27, 2015, 4:55:55 PM12/27/15
to Matthew Hodges, Node-Neo4j Discussion
Hi Matt,

The headers option is supposed to be a dictionary of key value pairs, similar to Node's native http method. Hope that helps!

Cheers,
Aseem

Matthew Hodges

unread,
Dec 28, 2015, 9:48:42 AM12/28/15
to Aseem Kishore, Node-Neo4j Discussion
Thanks Aseem, it's working.  So it's hdrs={  'content-type': 'application/json' }  etc.

Best,
Matt
Reply all
Reply to author
Forward
0 new messages