1

I'm trying to access the rest api of my local Neo4j instance. I have read the docs which state that in order to log in you must supply an Authorization header such as the following:

Authorization: Basic {base64 string}

This works perfectly for GET http://localhost/user/neo4j as expected, but it fails with the following message for GET http://localhost/db/data:

{"errors": [{ "code": "Neo.ClientError.Security.Unauthorized", "message": "No authentication header supplied." }]}

Does anyone know what I am doing wrong?

neo4j 3.6 on Mac OSX Sierra

James Hamilton
  • 457
  • 3
  • 16
  • What version of Neo4j? Are you wanting to send Cypher? Does it work with the [Cypher transactional endpoint](https://neo4j.com/docs/developer-manual/current/http-api/#http-api-transactional), `POST http://localhost:7474/db/data/transaction/commit` ? – William Lyon Dec 22 '16 at 19:22
  • Thanks for asking - I've added the version to the question. All I am trying to do is to get a JSON response from the root, I am no further forward than that. I am trying to develop my understanding by working through the examples in the manual. – James Hamilton Dec 22 '16 at 22:35
  • Yes, it works with the Cypher transactional endpoint – James Hamilton Dec 23 '16 at 12:38

2 Answers2

1

So I had the same problem and kicked myself when I eventually discovered the problem.

You need the trailing / try using the url http://localhost/db/data/

Djarid
  • 446
  • 4
  • 11
0

I had the same issue. I found this on SO a while ago, but can't find it anymore. First, a little clarification. Neo4j is looking for a base64 encoded string with the syntax "username:password".

To get that use this Convert UTF-8 to base64 string reference

var bytes = Encoding.UTF8.GetBytes("foo:pwd");
var base64 = Convert.ToBase64String(bytes);
Console.WriteLine(base64);

(Note: I'm using Postman). Now that you have a properly formatted base64 string, add this to your header: Authorization Basic

screencap of Postman

Community
  • 1
  • 1
Pman
  • 1
  • 1
  • Thanks very much for your response, but I think you've misread my question; I'm already including those headers. – James Hamilton Jan 03 '17 at 11:59
  • This may be a config file issue. see if this works `http://username:password@localhost:7474` – Pman Jan 10 '17 at 04:17
  • I was getting this error in Neo4j Browser, I have to hit the same query multiple times until suddenly / randomly it runs without error – Mahesha999 May 04 '17 at 09:53