0

I need to set the password for Neo4j and can do it from the command line like this:

curl -H "Content-Type: application/json" \
   -H "Authorization: Basic `echo -n 'neo4j:neo4j' | base64`" \
   -X POST -d '{"password":"nopass"}' \
   http://localhost:7474/user/neo4j/password

but I'm now trying to do it in node.js like this:

var f = require('node-fetch');
var url = 'http://neo4j:n0p4ss@localhost:7474/user/neo4j/password';
var auth = new Buffer('neo4j:neo4j').toString('base64');
f(url, {
    method: 'POST',
    body: {'password': 'nopass'},
    headers: {
        'Content-Type': 'application/json',
        'Authorization': 'Basic ' + auth
    }   
})
.then(res => res.text())
.then(txt => { console.log(txt); });

however, what I get back is:

{
  "errors" : [ {
    "code" : "Neo.ClientError.Request.InvalidFormat",
    "message" : "Required parameter 'password' is missing."
  } ]
}

which to me means the body: {...} isn't getting sent correctly. can anyone see what's wrong with my code?

ekkis
  • 9,804
  • 13
  • 55
  • 105

1 Answers1

0

ah. figured it out. it needs:

body: JSON.stringify({'password': 'nopass'}),
ekkis
  • 9,804
  • 13
  • 55
  • 105