我正在尝试通过 Java 中的 IBM Watson API 将文档添加到我的 IBM Bluemix Discovery 实例的集合中。对于给定的文件,我执行以下操作:
Discovery discovery = new Discovery("2017-08-01");
discovery.setEndPoint("https://gateway.watsonplatform.net/discovery/api");
discovery.setUsernameAndPassword("{username}", "{password}");
String environmentId = "{environment_id}";
String collectionId = "{collection_id}";
File f = new File("path/to/file");
String path = f.getPath();
String ext = FilenameUtils.getExtension(f.getName());
CreateDocumentRequest.Builder builder = new CreateDocumentRequest.Builder(environmentId, collectionId).documentId(path).file(f);
CreateDocumentResponse createResponse = discovery.createDocument(builder.build()).execute();
System.out.println(createResponse.toString());
但是,当我执行我的程序时,我得到了错误Exception in thread "main" com.ibm.watson.developer_cloud.service.exception.NotFoundException: Unknown API: POST [...]
,它来自createResponse
初始化的行。
谢谢你。