调用confuence api接口 返回的状态码302问题
黑暗的笑 2016-08-16 11:38:00 调用confluence api创建一个一个页面
HttpPost httpPost = new HttpPost("http://xxxxxx/confluence/rest/api/content/");
httpPost.addHeader(HEADER_AUTHORIZATION , AUTHORIZATION_CON);
httpPost.addHeader(HTTP.CONTENT_TYPE , "application/json");
JSONObject obj = new JSONObject();
obj.put("type" , "page").put("title", "picture test").put("space", new JSONObject().put("key", "xxx")).put("body", new JSONObject()
.put("storage", new JSONObject().put("value", "<p>This is a new page</p>").put("representation", "storage")));
HttpResponse res = null;
StringEntity se = null;
try {
se = new StringEntity(obj.toString());
httpPost.setEntity(se);
res = httpClient.execute(httpPost);
System.out.println(res.getStatusLine().getStatusCode());
System.out.println(res.getHeaders("location")[0]);
String entity = EntityUtils.toString(res.getEntity());
System.out.println(entity);
} catch (Exception e) {
e.printStackTrace();
}
调用confuence api接口 返回的状态码302问题