如何在Java中下载unirest发布呼叫响应?

时间:2019-10-15 08:45:50

标签: java api unirest

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。 我该怎么办?

0 个答案:

没有答案