0
votes

Google Datastore Runquery provides http client to perform GQL query as like below:

POST https://datastore.googleapis.com/v1/projects/my-project-id:runQuery?key={YOUR_API_KEY}

{
 "gqlQuery": {
  "queryString": "SELECT * FROM User WHERE email = '[email protected]'"
 }
}

But I am getting error response like:

{
  "error": {
    "code": 400,
    "message": "Disallowed literal: '[email protected]'.",
    "status": "INVALID_ARGUMENT"
  }
}

But, Google Cloud Datastore Http Client work perfectly with simple query like 'Select * from User'.

So, How can this GQL Query be executed with Datastore Http client?

1

1 Answers

2
votes

You have to set the allowLiterals parameter to true or use bindings for the parameters (either named or positional).

See the documentation below:

https://cloud.google.com/datastore/reference/rest/v1/projects/runQuery#GqlQuery

So if you want to allow literals (constant values) in the query, you should change the request to

{
 "gqlQuery": {
  "queryString": "SELECT * FROM User WHERE email = '[email protected]'"
  "allowLiterals": true
 }
}