我正在开发一个Java客户端来调用Rest服务https。 我需要创建一个多部分表单数据请求,但是服务器响应出现错误。
在请求中,我必须在“文档”字段中发送文件。
以下是Java代码:
File f = new File(filepath);
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);
builder.addBinaryBody("document", new FileInputStream(f), ContentType.APPLICATION_OCTET_STREAM, f.getName() );
HttpEntity entity = builder.build();
服务器响应:
Response code: 404
404 - File or directory not found.
The resource you are looking for might have been removed, had its name changed, or is temporarily unavailable.