How to POST NON-JSON request using Apache HttpClient?
问题 I am to hitting an API which will return string data and as well I want to send data of string type(textfile in a paragraph). 回答1: You can use Apache httpcomponents, with http entities Here is an example for sending a file in your POST request: File file = new File("somefile.txt"); FileEntity entity = new FileEntity(file, ContentType.create("text/plain", "UTF-8")); HttpPost httppost = new HttpPost("http://localhost/action.do"); httppost.setEntity(entity); If you want a text content, you can