Search code examples
neo4jheadergraph-databasesneo4jclientcustom-headers

NEO4J: CustomHeaders overwrite default header?


i'm currently trying to add a field into the Header of my Cypher request to tell the load-balancer wether it's a write or read request so it directs the query on Master or Slave Neo4j instance.

HttpClientWrapper clientWrapper = new HttpClientWrapper(ConfigurationManager.AppSettings["Neo4jUserName"], ConfigurationManager.AppSettings["Neo4jPassword"]);

Uri uri = new Uri(ConfigurationManager.AppSettings["Neo4jClient"]);
GraphClient client = new GraphClient(uri, clientWrapper);
client.JsonConverters.Add(new CoordinateConverter());
client.Connect();
...        
NameValueCollection collection = new NameValueCollection();
collection.Add("X:Write", "1");
...
client.Cypher.CustomHeader(collection)...

But when executing the query, i'm getting Exception such as:

System.FormatException: "The header name format is invalid."

My question is, do the .CustomHeader(collection) override the standard Header instead of only adding the field X:Write ? I'm struggling to find documentation on CustomHeader and how it's supposed to work.

Thanks in advance for reading me.

EDIT: Here is some code examples i found and should work: https://github.com/Readify/Neo4jClient/pull/149/files


Solution

  • The error was that i couldn't use ':' in the headername, changing the name to "IsWrite" solved the problem.