How to POST a request in any of rest clients for mime type as “multipart/related”

心不动则不痛 提交于 2019-12-14 03:59:24

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!