Failed to invoke procedure `apoc.nlp.gcp.entities.stream`: Caused by: java.io.IOException

Hi,
I am using desktop version of Neo4j 4.0.3 with GDS and APOC (apoc-4.0.0.12-all.jar & apoc-nlp-dependencies-4.0.0.12.jar) plugins.
I issue following command in Cypher
MATCH (a:Article {uri: "Pokégraph: Gotta Graph 'Em All!"})
CALL apoc.nlp.gcp.entities.stream(a, {
key: '',
nodeProperty: "body"
})
YIELD value
UNWIND value.entities AS entity
RETURN entity;

Whenever I execute the above command, I receive the following error:

Neo.ClientError.Procedure.ProcedureCallFailed

Failed to invoke procedure apoc.nlp.gcp.entities.stream: Caused by: java.io.IOException: Server returned HTTP response code: 403 for URL: https://language.googleapis.com/v1/documents:analyzeEntities?key=

I have the API key setup in my project and also enabled services in GCP project
NAME TITLE
endpoints.googleapis.com Google Cloud Endpoints
servicecontrol.googleapis.com Service Control API
servicemanagement.googleapis.com Service Management API

Please help in resolving the above issue.

Thanks & Regards,
Rajeev

1 Like

I think that error code is an auth based one. Is the key that it shows in the error message the one that you expect to see?

Maybe check if the api key you are using has any set limitations?

I am encountering a somewhat similar issue, but mine is 400 error code. The query runs OK every now and then, So i am sure that the apikey is correct. But every so often, i get the error message:

"Failed to invoke procedure apoc.nlp.gcp.entities.stream: Caused by: java.io.IOException: Server returned HTTP response code: 400 for URL: https://language.googleapis.com/v1/documents:analyzeEntities?

Anyone with clue as to what I need to do to fix this?

Update:
the string that was triggering the errors:
"General Medicine"
"Molecular Medicine"

I replaced the " " with a "-" in front of "Medicine" and the HTTP 400 error went away:
trim(toUpper(replace(n.Title," Medicine","-Medicine" )))

Weird!!

Do you mean having those phrases in the node property that you're analyzing causes the error? That sounds very weird, I'd like to investigate it so that we can sort it out

Failed to invoke procedure apoc.nlp.gcp.entities.stream: Caused by: java.io.IOException: Server returned HTTP response code: 400
i do have a same issue can any one help me with this

Is it repeatable? Can you share the data/query that resulted in that error?

1 Like

MATCH (a:Article {uri: "Pokégraph: Gotta Graph 'Em All!"})
CALL apoc.nlp.gcp.entities.graph(a, {
key: $apiKey,
nodeProperty: "body",
writeRelationshipType: "ENTITY"
})
YIELD graph AS g
RETURN g;

Oh that's strange. I just created a new guide showing how to use the procedures so I have tested out something very similar to that query - Entity Extraction with APOC NLP - Developer Guides

Does your API key definitely have all the required permissions?

yes i do can u please help me with creating the relation between the nodes dynamicaly for a given text and also i dint get same version of graphware nlp's in the git hub i need 3.5.1 version of standford nlp can u me help me with this please..

Hi Mark,

I have the same error as rajeev1.s
Failed to invoke procedure apoc.nlp.gcp.entities.stream: Caused by: java.io.IOException: Server returned HTTP response code: 403 for URL: https://language.googleapis.com/v1/documents:analyzeEntities?key=(key here)

However, I it is unclear which permissions the API key needs to have. I'm following this tutorial (Tutorial: Build a Knowledge Graph using NLP and Ontologies - Developer Guides) and the explanation is quite brief (Assuming that we’re already created a GCP account, we can generate a key by following the instructions at console.cloud.google.com/apis/credentials). Could you provide me with the steps necessary to check if the API key has all the required permissions?

For now, I don't have any restrictions.

Thanks,
Rose

@rosemary.thatsme I had the same issue. Try visiting https://console.developers.google.com/apis/api/language.googleapis.com/overview?project=*YOUR-GCP-PROJECT-ID* to enable it.

(Below is how I figured that out, by calling the GCP natural language API from the command line)

$ curl  -XPOST 'https://language.googleapis.com/v1/documents:analyzeEntities?key=MY-API-KEY  
{
  "error": {
    "code": 403,
    "message": "Cloud Natural Language API has not been used in project *MY-PROJECT-ID* before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/language.googleapis.com/overview?project=*MY-PROJECT-ID* then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.",
    "status": "PERMISSION_DENIED",
    "details": [
      {
        "@type": "type.googleapis.com/google.rpc.Help",
        "links": [
          {
            "description": "Google developers console API activation",
            "url": "https://console.developers.google.com/apis/api/language.googleapis.com/overview?project=*MY-PROJECT-ID*"
          }
        ]
      },
      {
        "@type": "type.googleapis.com/google.rpc.ErrorInfo",
        "reason": "SERVICE_DISABLED",
        "domain": "googleapis.com",
        "metadata": {
          "consumer": "projects/*MY-PROJECT-ID*",
          "service": "language.googleapis.com"
        }
      }
    ]
  }
}

After enabling it, I was able to continue with the Neo4j tutorial (Tutorial: Build a Knowledge Graph using NLP and Ontologies - Developer Guides)