Java 如何将多部分/混合负载作为多部分使用?

Java 如何将多部分/混合负载作为多部分使用?,java,multipart,mixed,Java,Multipart,Mixed,我找到了一个RESTAPI,它使用multipart/mixed数据和有效负载,但RESTAPI将其作为字符串。如果我尝试其他对象作为Multipart,RequestPart则会抛出415 UnsupportedMediaType异常 这是我传递的多部分/混合有效负载: POST /users/jsonform HTTP/1.1 Content-Type: multipart/mixed; boundary=----------boundary Content-Length: 963 ---

我找到了一个RESTAPI,它使用
multipart/mixed
数据和有效负载,但RESTAPI将其作为字符串。如果我尝试其他对象作为
Multipart
,RequestPart则会抛出
415 UnsupportedMediaType异常

这是我传递的
多部分/混合
有效负载:

POST /users/jsonform HTTP/1.1
Content-Type: multipart/mixed; boundary=----------boundary
Content-Length: 963

----------boundary
Content-Length: 337
Content-Type: application/json
content-id: 1

GET http://localhost:9090/users/user/1

----------boundary
Content-Length: 353
Content-Type: application/json
content-id: 2
content-transfer-encoding: binary

POST http://localhost:9090/users/addUser

{
    "firstName": "Test",
    "lastName": "Test"
}

----------boundary--
@POST 
@Path("/jsonform") 
@Consumes("multipart/mixed") 
public void simpler(String inputs) throws MessagingException, IOException {
    System.out.println(inputs);
}
如果我传递一个字符串参数,它将有效负载作为字符串读取,但是如果我传递的不是字符串,那么它将抛出一个错误

我得到一个错误:

HTTP Status [415] – [Unsupported Media Type]