创建Google Cloud在线术语表时遇“Empty resource name”错误求助
Hey there, let's break down this error and get your glossary created successfully!
What's Causing the Error?
The 400 INVALID_ARGUMENT error clearly states that your request is missing a required piece of information: the unique identifier for your glossary. When creating a Cloud Translate glossary, the API needs to know what to name your resource—without this, it can't create or identify the glossary you're trying to build.
Fixing the Request JSON
Your current request.json only includes language settings and the GCS input path, but it's missing the glossaryId field (this is the unique name you want to give your glossary). Add this field to your JSON, like so:
{ "glossaryId": "multi-language-terms-glossary", "languageCodesSet": { "languageCodes": ["en", "en-GB", "ru", "fr", "pt-BR", "pt-PT", "es"] }, "inputConfig": { "gcsSource": { "inputUri": "gs://focused-pipe-251317-vcm/testgc.csv" } } }
Replace multi-language-terms-glossary with a name that makes sense for your use case—just make sure it's unique within your project and location.
Additional Checks to Ensure Success
Once you've added the glossaryId, double-check these details to avoid other potential issues:
- CSV File Format: For a multi-language glossary, your CSV must have language codes as the first row (matching the codes in your
languageCodeslist), with each subsequent row containing the corresponding terms for each language. - API Request Endpoint: Make sure your
rungcglossaryscript is sending the request to the correct endpoint, which includes your project ID and a valid location (e.g.,us-central1). The full endpoint should look like:https://translation.googleapis.com/v3/projects/focused-pipe-251317/locations/us-central1/glossaries - GCS Permissions: Verify that the service account running the script has
storage.objects.getpermissions for the GCS bucket holding your CSV—this ensures the API can access the file to build the glossary.
内容的提问来源于stack exchange,提问作者madan kandula

