响应状态为:401 Unauthorized - neo4j

时间:2017-10-26 17:09:16

标签: c# neo4j neo4jclient

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

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

  

:播放电影

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

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 =真

仍为假,不解决问题

1 个答案:

答案 0 :(得分:0)

创建GraphClient实例时,您应该传递用户名和密码。类似的东西:

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

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