1
我正尝试通过Java中的IBM Watson API将文档添加到IBM Bluemix Discovery实例的集合中。对于给定的文件,我做如下:IBM Watson:将文档添加到集合时出现未知API错误
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
初始化行。
谢谢。
谢谢。它解决了这个问题。但是,现在我会提出一个问题。如果我想根据其路径搜索特定的文档,我该怎么做?我需要文档ID,看起来后者在CreateDocumentRequest的响应中只给出一次。我是否必须将这些ID映射到文件中的相应路径?同样的问题适用于删除文件。 –
我更新了它! – TonyY