设置角色权限
效果
public static void main(String[] args) {
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("text/plain");
MultipartBody body = new MultipartBody.Builder().setType(MultipartBody.FORM)
.addFormDataPart("form_data","{\"datasource\":{\"id\":2,\"type\":\"table\"},\"force\":false,\"queries\":[{\"time_range\":\"No+filter\",\"filters\":[{\"col\":\"sex\",\"op\":\"IS NOT NULL\"}],\"extras\":{\"time_range_endpoints\":[\"inclusive\",\"exclusive\"],\"having\":\"\",\"having_druid\":[],\"where\":\"\"},\"applied_time_extras\":{},\"columns\":[\"sexName\"],\"metrics\":[\"count\"],\"annotation_layers\":[],\"row_limit\":100,\"timeseries_limit\":0,\"order_desc\":true,\"url_params\":{},\"custom_params\":{},\"custom_form_data\":{}}],\"result_format\":\"json\",\"result_type\":\"results\"}")
.build();
Request request = new Request.Builder()
.url("http://localhost:8088/api/v1/chart/data")
.method("POST", body)
.build();
Response response = client.newCall(request).execute();
Gson gson = new Gson();
Map map = gson.fromJson(response.body().string(), Map.class);
System.out.println(map.get("result"));
}