google-app-enginecurlgoogle-cloud-platformgoogle-cloud-firestoregoogle-translate

google cloud online glossary creation returning "empty resource name" error


I am following the EXACT steps indicated here https://cloud.google.com/translate/docs/glossary#create-glossary

to create a online glossary.

I am getting the following error

madan@cloudshell:~ (focused-pipe-251317)$ ./rungcglossary
{
  "error": {
    "code": 400,
    "message": "Empty resource name.;  Resource type: glossary",
    "status": "INVALID_ARGUMENT"
  }
}

Here is the body of my request.json

{
  "languageCodesSet": {
    "languageCodes": ["en", "en-GB", "ru", "fr", "pt-BR", "pt-PT", "es"]
  },
  "inputConfig": {
    "gcsSource": {
"inputUri": "gs://focused-pipe-251317-vcm/testgc.csv"
    }
  }
}

The inputUri path i copied from the google cloud bucket file URI box.

I am not able to understand what the issue is. All I know is something is wrong with the inputUri string.

Please help.

Thanks.


Solution

  • I am a Google Cloud Technical Support Representative and we know that, for the moment, there is an issue with the REST API which is on track. I tried to reproduce your situation and while trying to create the glossary using directly the API I got the same issue as you.

    After that, I have tried to create the glossary programmatically using a HTTP Triggered Python Cloud Function and everything went just right. In this manner your API will be called with the Cloud Functions service account.

    I will attach the code of my Python Cloud function:

    from google.cloud import translate_v3beta1 as translate
    
    def create_glossary(request):
        request_json = request.get_json()
        client = translate.TranslationServiceClient()
        ## Set your project name
        project_id = 'your-project-id'
        ## Set your wished glossary-id
        glossary_id = 'your-glossary-id'
        ## Set your location
        location = 'your-location'  # The location of the glossary
    
        name = client.glossary_path(
            project_id,
            location,
            glossary_id)
    
        language_codes_set = translate.types.Glossary.LanguageCodesSet(
            language_codes=['en', 'es'])
        ## SET YOUR BUCKET URI
        gcs_source = translate.types.GcsSource(
            input_uri='your-gcs-source-uri')
    
        input_config = translate.types.GlossaryInputConfig(
            gcs_source=gcs_source)
    
        glossary = translate.types.Glossary(
            name=name,
            language_codes_set=language_codes_set,
            input_config=input_config)
    
        parent = client.location_path(project_id, location)
    
        operation = client.create_glossary(parent=parent, glossary=glossary)
    
        result = operation.result(timeout=90)
        print('Created: {}'.format(result.name))
        print('Input Uri: {}'.format(result.input_config.gcs_source.input_uri))
    

    The requirements.txt should include the following dependencies:

    google-cloud-translate==1.4.0
    google-cloud-storage==1.14.0
    

    Do not forget to modify the code with your parameters

    Basically, I have just followed the same tutorial as you, but for Python and I used Cloud Functions. My guess is that you can use App Engine Standard, as well.This may be an issue regarding the service account that are used to call this API. In case this doesn´t work for you let me know and I will try to edit my comment.