http://hc.apache.org/downloads.cgi
CloseableHttpClient httpclient = HttpClients.createDefault();
HttpPost post = new HttpPost("https://cloud.securenettech.com/snadmindev2/j_spring_security_check?j_username=2079001&j_password=2079001&mobile=true");
post.addHeader("Context-Type", "application/json");
httpclient.execute(post);
HttpGet httpGet = new HttpGet("https://cloud.securenettech.com/snadmindev2/rest/api/v1/dp/c/accountSummaryPDF/accountSummary51840783060577745.pdf");
System.out.println("Executing request " + httpGet.getRequestLine());
ResponseHandler<String> responseHandler = new BasicResponseHandler(){
public String handleResponse(final HttpResponse response)throws ClientProtocolException, IOException {
int status = response.getStatusLine().getStatusCode();
System.out.println("status= " + status);
if(status >=200 && status <=300){
HttpEntity entity = response.getEntity();
return entity != null ? EntityUtils.toString(entity) : null;
}else{
throw new ClientProtocolException("Unexpected status "+ status);
}
}
};
String responseBody = httpclient.execute(httpGet, responseHandler);
Немає коментарів:
Дописати коментар