google-translate - Google Translation V3 API - 词汇表资源错误
问题描述
创建了一个词汇表资源——步骤 1)在 GCS 中保留一个词汇表 csv 表。步骤 2) request.json 如下 -
{
"name":"projects/my-project-id/locations/us-central1/glossaries/my-glossary-id",
"languagePair": {
"sourceLanguageCode": "en",
"targetLanguageCode": "ru"
},
"inputConfig": {
"gcsSource": {
"inputUri": "gs://my-bucket-id/my-glossary-id.csv"
}
}
}
步骤 3) curl -X POST -H "Authorization: Bearer"$(gcloud auth application-default print-access-token) -H "Content-Type: application/json; charset=utf-8" -d @request.json https://translation.googleapis.com/v3/projects/my-project-id/locations/us-central1/glossaries
得到以下回应 -
{
"name": "projects/my-project-id/locations/us-central1/operations/20210322-02431616406238-605596c9-0000-21a9-91e6-94eb2c045d66",
"metadata": {
"@type": "type.googleapis.com/google.cloud.translation.v3.CreateGlossaryMetadata",
"name": "projects/my-project-id/locations/us-central1/glossaries/my-glossary-id",
"state": "RUNNING",
"submitTime": "2021-03-22T09:43:58.973617420Z"
}
}
但是当我想列出词汇表时-它返回一个空白:-
curl -X GET -H "授权:承载"$(gcloud auth application-default print-access-token) https://translation.googleapis.com/v3/projects/my-project-id/locations/us-central1/词汇表
响应如下——{}
另外 - 当我使用这个词汇表翻译我的文本时 - 它会抛出错误 -
{
"error": {
"code": 404,
"message": "Glossary not found.; Failed to initialize a glossary.",
"status": "NOT_FOUND"
}
}
解决方案
推荐阅读
- python - Python:Bloomberg API 无法获取令牌。无授权
- android - Android:混合FCM消息的优先级是什么
- python - Windows ubuntu 上的 Python Kivy 构建错误
- c# - 如何在 Linux 上的 C# 中按特定的 SortVersion 比较字符串?
- javascript - 使用 Fabric.js 访问 SVG 属性
- regex - 这些字符串的正则表达式
- html - 隐藏元素仍在下拉导航中占用空间
- javascript - 如何合并和汇总来自 MongoDB 的结果
- c# - 如何在类中初始化不可为空的字符串?
- java - 什么是 JSON 等价于 @XmlAnyElement?