Neo4jClient returns 403 FORBIDDEN: Request forbidden by administrative rules
See original GitHub issueWhen trying to add a relationship between two nodes in a neo4j instance using Neo4jClient, I get the following error: Request forbidden by administrative rules.
`public async Task CreateFollowship(Guid followerId, Guid followedId) { await _neo4jClient.ConnectAsync();
await _neo4jClient.Cypher
.Match("(follower:User)", "(followed:User)")
.Where($"(User follower) => follower.Id == {followerId}")
.AndWhere($"(User followed) => followed.Id == {followedId}")
.Create("follower-[:FOLLOWS]->followed")
.ExecuteWithoutResultsAsync();
}`
The query generated is (by example):
MATCH (follower:User), (followed:User) WHERE (User follower) => follower.Id == "970486dc-5430-4532-8ed3-e30efa930105" AND (User followed) => followed.Id == "f6a15b31-e328-4113-8541-3de8108b116d" CREATE follower-[:FOLLOWS]->followed
I tried in other ways:
MATCH (follower:User), (followed:User) WHERE follower.Id == "970486dc-5430-4532-8ed3-e30efa930105" AND followed.Id == "f6a15b31-e328-4113-8541-3de8108b116d" CREATE follower-[:FOLLOWS]->followed
MATCH (follower:User), (followed:User) WHERE follower.Id IS "970486dc-5430-4532-8ed3-e30efa930105" AND followed.Id IS "f6a15b31-e328-4113-8541-3de8108b116d" CREATE follower-[:FOLLOWS]->followed
When running the command on the Neo4j Console using Cypher, i get different syntax errors with every attempt to fix. What is the correct syntax? An incorrect syntax is really the reason for the 403 error?
Issue Analytics
- State:
- Created 9 months ago
- Comments:8 (4 by maintainers)
HI @guilhermedjr, correct Cypher syntax is
Unless it is intended, I would recommend using MERGE instead of CREATE to prevent creating multiple similar relationsships between the nodes.
Using Neo4jClient in C# this would be (with Create replaced by Merge):
or alternatively by using string and parameters
Params could also be set using just one “.WithParams” instead of the two “.WithParam”, but I like using it one by one.
Where-Clauses also could be set using string interpolation ($“follower.Id = {followerId}”) but this is not recommended as it prevents query caching.
Be aware that Cypher doesn’t accept “==” (or “!=”) as operators, these only work in C#. Has to be “=” or “<>” in Cypher.
Response status 403 means “Bad Request” so it’s due to that incorrect syntax and not a bug in Neo4jClient.
Best, Reiner
I don’t see why you would have a problem with Aura and not allowing write operations from an external source - if you can connect to the server - then it should work fine.
What is your entire connection setup - i.e. how are you creating the
IGraphClient
?