2 qq 23871435 qq_23871435 于 2017.01.09 15:00 提问

.net 调用kylin esetful API

public static StringBuffer excute(String kylinIp, String para, String method, String params)
{
StringBuffer out = new StringBuffer();
try
{
URL url = new URL("http://" + kylinIp + "/kylin/api" + para);
System.out.println(url);
HttpURLConnection connection = (HttpURLConnection)url.openConnection();
connection.setRequestMethod(method);
connection.setDoOutput(true);
connection.setRequestProperty("Authorization", "Basic " + encoding);
connection.setRequestProperty("Content-Type", "application/json;charset=UTF-8");
if (params != null) {
byte[] outputInBytes = params.getBytes("UTF-8");
OutputStream os = connection.getOutputStream();
os.write(outputInBytes);
os.close();
}
InputStream content = (InputStream)connection.getInputStream();
BufferedReader in = new BufferedReader(new InputStreamReader(content));
String line;
while ((line = in.readLine()) != null) {
out.append(line);
}
in.close();
connection.disconnect();

        }
        catch (Exception e)
        {
            e.printStackTrace();
        }
        return out;
    }
Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!