测试 IBM Watson 发现服务的 Java API
Discovery discovery = new Discovery("2017-09-01");
System.out.println("Creating a new document...");
String documentJson = "{\"field\":\"value\"}";
InputStream documentStream = new ByteArrayInputStream(documentJson.getBytes());
AddDocumentOptions.Builder createDocumentBuilder =
new AddDocumentOptions.Builder(environmentId, collectionId);
createDocumentBuilder.file(documentStream).fileContentType( HttpMediaType.APPLICATION_JSON);
DocumentAccepted createDocumentResponse = discovery.addDocument(createDocumentBuilder.build()).execute();
应该工作而不会抛出任何异常。
最后一条语句“discovery.addDocument”抛出异常;错误消息是“文件不为空时文件名不能为空”