Search code examples
ibm-cloudibm-watsonwatson-assistant

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


I am trying to download the workspace from Watson assistant using python.

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 is working fine - below sample output

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

But while I am trying to export the workspace using response = assistant.get_workspace(workspace_id=workspace_id, export=True)

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

Note - I working on working on the workspace deployment automation.

Hope I get some help here.


Solution

  • Here is the script to download the workspace JSON Assitant

    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()