String jsonBody = "<Json input>";
HttpResponse<String> response = null;
RequestBodyEntity res=null;
String url = "<some url>";
try {
response = Unirest.post(url).header("content-type", "application/json").body(jsonBody).asString();
System.out.println("Response: " + response.getBody());
} catch (UnirestException e) {
Reporter.reportStatus("Fail", "Failure in Unirest call", "path is "+url);
}
File file = new File("<Location of the file>");
InputStream input = response.getRawBody();
try {
FileOutputStream report = convertInputStreamToFile(input, file);
} catch (Exception e) {
e.printStackTrace();
}
我希望对此帖子进行一些响应,并将其存储在“响应”中。 我想下载响应,最好下载到excelsheet。 我该怎么办?