我正在尝试使用下面的代码访问IBM Watson Discovery API(免费试用):
with open(filename, "r") as f:
res = discovery.test_configuration_in_environment(environment_id=env_id, configuration_id=cfg_id, file=f).get_result()
您可以在此处查看完整的代码文件:https://github.com/udacity/AIND-NLP-Bookworm/blob/master/bookworm.ipynb。运行此程序时出现以下错误:
---------------------------------------------------------------------------
WatsonApiException Traceback (most recent call last)
<ipython-input-10-17e98c795a32> in <module>()
3 filename = os.path.join(data_dir, "sample.html")
4 with open(filename, "r") as f:
----> 5 res = discovery.test_configuration_in_environment(environment_id=env_id, configuration_id=cfg_id, file=f).get_result()
6 print(json.dumps(res, indent=2))
/opt/conda/lib/python3.6/site-packages/watson_developer_cloud/discovery_v1.py in test_configuration_in_environment(self, environment_id, configuration, step, configuration_id, file, metadata, file_content_type, filename, **kwargs)
702 params=params,
703 files=form_data,
--> 704 accept_json=True)
705 return response
706
/opt/conda/lib/python3.6/site-packages/watson_developer_cloud/watson_service.py in request(self, method, url, accept_json, headers, params, json, data, files, **kwargs)
585 error_info = self._get_error_info(response)
586 raise WatsonApiException(response.status_code, error_message,
--> 587 info=error_info, httpResponse=response)
WatsonApiException: Error: The Preview API was removed on 2019-09-30., Code: 410 , X-dp-watson-tran-id: 569fbd407a75c23f850522571bddee26 , X-global-transaction-id: 569fbd407a75c23f850522571bddee26
任何已知的解决方法?
[根据发行说明和响应,您看到的Preview API
已于2019年6月4日弃用-https://cloud.ibm.com/docs/discovery?topic=discovery-release-notes#4jun19-并于2019年9月30日被删除-https://cloud.ibm.com/docs/discovery?topic=discovery-release-notes
发现API仍然可用-https://cloud.ibm.com/apidocs/discovery/discovery,但不是预览方法。
您正在尝试做什么?