How can I POST using Java and include parameters and a raw request body?

前端 未结 2 1075
醉酒成梦
醉酒成梦 2021-01-18 01:45

I am communicating with a web service that expects a POST parameter and also expect Request body. I have confirmed that such a POST request can be done using a REST Console

2条回答
  •  庸人自扰
    2021-01-18 02:10

    You need to make a POST request using multipart-form. Here is the example:

    Apache HttpClient making multipart form post

    Alternatively, you can make a POST request with the content (parameters and files) encoded using application/x-www-form-urlencoded but it is not recommended when you want to make a POST request with large content, like files.

提交回复
热议问题