python - 尝试在未配置 API 客户端的情况下使用服务客户端工厂

标签 python alexa-skills-kit

我正在尝试将 isp(技能购买中)添加到我的 Alexa Skill 中。技能代码是用 python 编写的,在启动请求处理程序中我编写了以下代码:

locale = handler_input.request_envelope.request.locale
monetization_service = handler_input.service_client_factory.get_monetization_service()
product_response = monetization_service.get_in_skill_products(locale)

if isinstance(product_response, InSkillProductsResponse):
   in_skill_product_list = product_response.in_skill_products
   self._logger.info(in_skill_product_list)

当我运行 lambda 时,出现以下错误:

Attempting to use service client factory with no configured API client

有没有人遇到过这个问题,让我知道它做错了什么?

最佳答案

在初始化我使用的技能构建器时

sb = SkillBuilder()

此 SkillBuilder 未配置 APIClient。相反,将其更改为

sb = StandardSkillBuilder() 

在配置了 ApiClient 后即可工作。

关于python - 尝试在未配置 API 客户端的情况下使用服务客户端工厂,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59584387/

相关文章:

python - 每天运行一次 Python 脚本(访问互联网)的最简单方法是什么?

python - lxml:如何从树中的给定元素创建新的元素树

python - 多维Python数组

amazon-web-services - 在 Amazon Web Services 控制台上上传 lambda 函数代码时出现问题

Alexa Nodejs sdk - withSimpleCard() 有什么作用?

amazon - alexa 在技能调用时发送 SessionEndedRequest

javascript - 如何从 ReactJS 网络应用程序向 Django API 发送 POST 请求?

python - 使用 python 抓取图像并更改其名称

javascript - 如何在 Alexa Skill 中重新启动对话框

node.js - 如何获取从 Alexa 响应到用户回复所耗时?