Unable to access Watson Assistant via Python API - Error: Resource not found, Code: 404

Unable to access Watson Assistant via Python API - Error: Resource not found, Code: 404

我正在尝试使用 python 从 Watson Assistant 下载工作区。

assistant = assistant = AssistantV1(
    version='2019-02-28',
    iam_apikey='',
    url='https://gateway-fra.watsonplatform.net/assistant/api'
)
language = 'en'
workspace_id = "" #Skill Name:Poor mans disambiguation
#Frankfurt: https://api.eu-de.assistant.watson.cloud.ibm.com

response=assistant.list_workspaces().get_result()
print(json.dumps(response, indent=2))

list.wokpace 工作正常 - 低于样本输出

{
  "workspaces": [
    {
      "name": "1 - DEV ENGLISH",
      "language": "en",
      "metadata": {
        "api_version": {
          "major_version": "v1",
          "minor_version": "2019-02-28"
        }

但是当我尝试使用导出工作区时 response = assistant.get_workspace(workspace_id=workspace_id, export=True)

ApiException: Error: Resource not found, Code: 404 , X-global-transaction-id: a5e6e2ff76d987798c7c844b232f7f18

注意 - 我致力于工作区部署自动化。

希望我能在这里得到一些帮助。

这可能是一个临时错误,或者您没有传入正确的工作区 ID。作为 V1 API 一部分的 get_workspace() API 需要工作区 ID,而不是技能 ID。

我有 Python tools based on V1 and V2 and here is the call to that get_workspace:

# Get and print a specific workspace by ID
def getPrintWorkspace(workspaceID,exportWS):
    print(json.dumps(assistant.get_workspace(workspace_id=workspaceID,export=exportWS).get_result(), indent=2))

它与记录的内容和您的调用类似,因此您的代码应该没问题。检查参数值。

这是下载工作区的脚本JSON助手

Api_key = ''
Skill_id = ''
Service_url = ''

start = time.time()
authenticator = IAMAuthenticator(Api_key)
assistant = AssistantV1(version='2019-02-28',authenticator = authenticator)
assistant.set_service_url(Service_url)
response=assistant.get_workspace(workspace_id=Skill_id).get_result()
end = time.time()
print("Execution time : ",end - start)

response = assistant.get_workspace(
    workspace_id=Skill_id, export=True).get_result()