Google app engine 谷歌云在线词汇表创建返回“;“空资源名称”;错误
我将按照此处所示的具体步骤进行操作 创建在线词汇表 我得到以下错误Google app engine 谷歌云在线词汇表创建返回“;“空资源名称”;错误,google-app-engine,curl,google-cloud-platform,google-cloud-firestore,google-translate,Google App Engine,Curl,Google Cloud Platform,Google Cloud Firestore,Google Translate,我将按照此处所示的具体步骤进行操作 创建在线词汇表 我得到以下错误 madan@cloudshell:~ (focused-pipe-251317)$ ./rungcglossary { "error": { "code": 400, "message": "Empty resource name.; Resource type: glossary", "status": "INVALID_ARGUMENT" } } 这是我的request.json的主体
madan@cloudshell:~ (focused-pipe-251317)$ ./rungcglossary
{
"error": {
"code": 400,
"message": "Empty resource name.; Resource type: glossary",
"status": "INVALID_ARGUMENT"
}
}
这是我的request.json的主体
{
"languageCodesSet": {
"languageCodes": ["en", "en-GB", "ru", "fr", "pt-BR", "pt-PT", "es"]
},
"inputConfig": {
"gcsSource": {
"inputUri": "gs://focused-pipe-251317-vcm/testgc.csv"
}
}
}
我从google cloud bucket文件URI框复制的inputUri路径
我无法理解问题是什么。我只知道inputUri字符串有问题
请帮忙
谢谢。我是谷歌云技术支持代表,我们知道,目前REST API存在一个问题。我试图重现您的情况,在尝试直接使用API创建术语表时,我遇到了与您相同的问题 在那之后,我尝试使用HTTP触发器以编程方式创建词汇表,一切都进行得很顺利。通过这种方式,将使用云函数服务帐户调用API 我将附上Python云函数的代码:
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))
requirements.txt应包括以下依赖项:
google-cloud-translate==1.4.0
google-cloud-storage==1.14.0
不要忘记使用参数修改代码
基本上,我刚刚学习了与您相同的教程,但是对于Python和我使用了云函数。我猜你也可以使用App Engine Standard。这可能是关于用于调用此API的服务帐户的问题。如果这对您不起作用,请告诉我,我将尝试编辑我的评论。您的示例中有一些小的更正,但它起了作用。我仍然需要测试词汇表本身是否给了我有意义的翻译,但这是另一个主题:)谢谢!这是在创建单向术语表还是等效术语表?是的。它与您所遵循的教程完全相同,但使用Python以编程方式编写。