So I've looked into many solutions here , but couldn't find this...
Say I have json file "myFile.json" - it hold the body of the request Say I have this path as destination URL : "http://1.1.1.7:80/myService/publish"
All I want to do is send this file to the destination.
Here is a code I'm using (found it here in one of the threads)
public class HttpClientExample {
public static void main(String[] args) throws Exception {
String payload = "data={"myFile.json"};
StringEntity entity = new StringEntity(payload,
ContentType.APPLICATION_FORM_URLENCODED);
HttpClient httpClient = HttpClientBuilder.create().build();
HttpPost request = new HttpPost("http://1.1.1.7:80/myService/publis");
request.setEntity(entity);
HttpResponse response = httpClient.execute(request);
System.out.println(response.getStatusLine().getStatusCode());
}
}