该请求被拒绝,因为在Docushare Flex中创建新文档时没有发现多个边界



我正在尝试使用新的docushare rest api在docushare flex中创建新文档,而我的请求主体则为xml,并且我正在使用请求的数据生成它,当我发送请求时,我得到了此错误" org.apache.commons.fileupload.fileuploadexception:请求被拒绝,因为找不到多部分边界"

    HttpPost request = new HttpPost(postUrl);
    String filePath = "C:/Test/CreateDocument.xml";
    String createObj =  helper.createDocumentXml(filePath, parentId, documentTitle, fileName, ownerId);
    String createDocumentXml= null;
    {
        try {
            createDocumentXml = FileUtils.readFileToString(new File(filePath));
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    StringEntity bodyEntity = new StringEntity(createDocumentXml, ContentType.MULTIPART_FORM_DATA);
    request.setEntity(bodyEntity);
    CloseableHttpResponse response =  client.execute(request);
    System.out.println("Status is " +  response.getStatusLine());
    HttpEntity entity = response.getEntity();

我已经使用了此代码块上传文档flex

HttpPost request = new HttpPost(postUrl);
String filePath = "C:/Test/CreateDocument.xml";
String createObj =  helper.createDocumentXml();
String createDocumentXml= null;
{
    try {
        createDocumentXml = FileUtils.readFileToString(new File(filePath));
    } catch (IOException e) {
        e.printStackTrace();
    }
}
    FileBody body = new FileBody(file.toFile());
    StringBody xmlContent = new StringBody(createDocumentXml, ContentType.APPLICATION_XML);
    String boundry = UUID.nameUUIDFromBytes(file.toString().getBytes()).toString();
    HttpEntity entity = MultipartEntityBuilder.create()
            .setBoundary(boundry)
            .setCharset(Charset.forName("UTF-8"))
            .setMode(HttpMultipartMode.BROWSER_COMPATIBLE)`enter code here`
            .addPart("content", body)
            .addPart("request", xmlContent)
            .build();
    request.setEntity(entity);
    CloseableHttpResponse response =  client.execute(request);
    HttpEntity entity = response.getEntity();

最新更新