问题
I'm trying to do a POST request from any of rest client like (Advanced rest client, Postman etc) for posting a request with mime type "multipart/related" but none of rest client supports. So is there a way to quickly POST a request from any of rest clients or other alternate solutions?
回答1:
Though I have not tried multipart/related, but multipart/mixed using jersey client.
Using Jersey client
Create a multipart request .. eg.
MultiPart multiPart = new MultiPart();
multiPart.bodyPart(....//
Then call the service like :
Client c = Client.create();
WebResource service = c.resource(Url);
ClientResponse response = service.type("multipart/mixed").header(headerkey,
headervalue).post(ClientResponse.class, multiPart);
Similarly try it for multipart/related.
you have download jersery client jar from https://jersey.java.net/download.html
回答2:
Attached image will help you, This way you can try using Advance Rest Client plugin in Chrome, and also don't forget to upload the file under the Files tab.
来源:https://stackoverflow.com/questions/20676206/how-to-post-a-request-in-any-of-rest-clients-for-mime-type-as-multipart-related