我正在尝试使用“googleapis/python-retail”Python 包将产品导入 Recommendations AI 目录。但是当我使用 ProductServiceAsyncClient 执行此操作时,会向我返回一个错误"google.api_core.exceptions.GoogleAPICallError: None Unexpected state: Long-running operation had neither response nor error set."
在“推荐 AI -> 数据 -> 导入活动”中,我没有任何日志。我也没有错误
我尝试使用此包获取手动上传的产品并再次导入以排除格式错误。但它也失败了
我的示例代码:
async def import_products():
product_client = ProductServiceAsyncClient()
product_obj = Product(
id='product-id',
categories=["Larry", "Steve", "Eric"],
title='title',
)
product_items = [product_obj]
product_inline_source = ProductInlineSource(
products = product_items
)
product_input_config = ProductInputConfig(
product_inline_source = product_inline_source
)
import_products_request = ImportProductsRequest(
parent="projects/xxxxxxx/locations/global/catalogs/default_catalog/branches/default_branch",
input_config=product_input_config
)
import_products = await product_client.import_products(
request=import_products_request,
timeout=1000
)
return import_products
asyncio.run(import_products())