cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Neo4j.Driver.ClientException: 'Invalid input '?': expected whitespace, comment or an expression

BoltGraphClient _graphClient;
_graphClient = new BoltGraphClient(Uri, username, pass)
await _graphClient.ConnectAsync();
await _graphClient.Cypher
	.Merge("(User:User { Id: ?id })")
	.OnCreate()
	.Set("User = ?objuser")
	.WithParams(new
	{
		id = objuser.Id,
		objuser
	})
	.ExecuteWithoutResultsAsync();

For above I am getting error

Neo4j.Driver.ClientException: 'Invalid input '?': expected whitespace, comment or an expression
"MERGE (CommunityUser:CommunityUser { Id: ?id })"

How to solve this?
Can anyone provide code reference for DotNet - Neo4jClient 4.1 ?

1 ACCEPTED SOLUTION

Hi,

What Dana suggested is NOT the same thing you tried.

The first error message:

 'Invalid input '?': expected whitespace, comment or an expression (line 3, column 12 (offset: 62))
"SET user = ?objuser"

Is telling you the cypher is just invalid, and that it doesn't know how to interpret it

The second one:

The old parameter syntax {param} is no longer supported. Please use $param instead

Is telling you the syntax has changed, since 3.5 (IIRC) you now use $ instead.

All the best

Charlotte

View solution in original post

7 REPLIES 7

@abhishinde01 I suspect its tripping as a result of

.Merge("(User:User { Id: ?id })")

and

.Set("User = ?objuser")

and the usage of ?

Per cypher examples · DotNet4Neo4j/Neo4jClient Wiki · GitHub the example provided and when passing parameters is

var newUser = new User { Id = 456, Name = "Jim" };
graphClient.Cypher
    .Merge("(user:User { Id: {id} })")
    .OnCreate()
    .Set("user = {newUser}")
    .WithParams(new {
        id = newUser.Id,
        newUser
    })
    .ExecuteWithoutResults();

so if you change

	.Merge("(User:User { Id: ?id })")

to

	.Merge("(User:User { Id: {id} })")

and

.Set("User = ?objuser")

to

.Set("User = {objuser}")

does this address your issue

I am using Neo4jClient 4.1.14.0 and Neo4j.Driver 4.3.67.1
I tried this at first time but it was giving following error -

Neo4j.Driver.ClientException: 'The old parameter syntax {param} is no longer supported. Please use $param instead (line 1, column 42 (offset: 41))
"MERGE (User:User { Id: {id} })"

@abhishinde01 and given the error message which indicates 'The old parameter syntax {param} is no longer supported. Please use $param instead (line 1, column 42 (offset: 41))

if you change

MERGE (User:User { Id: {id} })"

to

MERGE (User:User { Id: $id })"

what is the outcome?

Thats the same issue i posted -

 await _graphClient.ConnectAsync();
             await _graphClient.Cypher
                 .Merge("(User:User { Id: ?id })")
                 .OnCreate()
                 .Set("User = ?objuser")
                 .WithParams(new
                 {
                     id = objuser.Id,
                     objuser
                 })
                 .ExecuteWithoutResultsAsync();

Neo4j.Driver.ClientException: 'Invalid input '?': expected whitespace, comment or an expression (line 1, column 42 (offset: 41))
"MERGE (CommunityUser:CommunityUser { Id: ?id })"

How to resolve this error?

I tried this as well -

 await _graphClient.Cypher
              .Match("(user:CommunityUser)")
               .Where((CommunityUser user) => user.Id == objuser.Id)
               .Set("user = ?objuser")
               .WithParam("objuser", new CommunityUser { Id = objuser.Id, FirstName = objuser.FirstName, LastName = objuser.LastName})
                .ExecuteWithoutResultsAsync();

This code giving me error -

Neo4j.Driver.ClientException: 'Invalid input '?': expected whitespace, comment or an expression (line 3, column 12 (offset: 62))
"SET user = ?objuser"

@abhishinde01
your original includes parameters referenced by / prefaced by a ?, for example

.Merge("(User:User { Id: ?id })")

I am suggesting you change this to parameters referenced by/prefaced by a $ and thus

.Merge("(User:User { Id: $id })")

Hi,

What Dana suggested is NOT the same thing you tried.

The first error message:

 'Invalid input '?': expected whitespace, comment or an expression (line 3, column 12 (offset: 62))
"SET user = ?objuser"

Is telling you the cypher is just invalid, and that it doesn't know how to interpret it

The second one:

The old parameter syntax {param} is no longer supported. Please use $param instead

Is telling you the syntax has changed, since 3.5 (IIRC) you now use $ instead.

All the best

Charlotte

Yes ... with $ its working absolutely fine
Thank you so much Guys