响应状态为:401 Unauthorized - neo4j

The response status was: 401 Unauthorized - neo4j

我成功安装了 neo4j 将默认密码 "neo4j" 更改为其他密码。

安装指南中的示例电影数据库

:play movies

这是我的控制台应用程序代码。

static void Main(string[] args)
         {
           var client = new GraphClient(new Uri("http://localhost:7474/db/data"));
           client.Connect();
           //query
           var results = client.Cypher
                         .Match(
                         "(actor:Person)-[:ACTED_IN]->(movie:Movie {title: {nameParam}})",
                         "(movie)<-[:DIRECTED]-(director:Person)"
                         )
                         .Return((actor, director, movie) => new
                         {
                             Movie = movie.As<Movie>(),
                             Actors = actor.CollectAs<Person>(),
                             Director = director.As<Person>()
                         })
                         .Results.Single();

               Console.WriteLine("{results.Movie.Title} directed by {results.Director.name}");
               foreach (var actor in results.Actors)
               {
               Console.WriteLine("\t{actor.name}");
               }
    }

但是得到了

的错误
The response from Neo4j (which might include useful detail!) was: {
  "errors" : [ {
    "code" : "Neo.ClientError.Security.Unauthorized",
    "message" : "No authentication header supplied."
   } ]
}

我什至改变

dbms.security.auth_enabled=True

还是假的,没有解决问题

您应该在创建 GraphClient 实例时传递用户名和密码。类似于:

var client = new GraphClient(new Uri("http://localhost:7474/db/data"), "neo4j", "mypassword");

此外,当 neo4j.conf 文件中的某些行发生更改时,您应该重新启动 neo4j 服务。