/**
* zabbix登录
*/
private static String zabbixLogin(String username, String password, String url) {
String loginBody = "{\n" +
" \"jsonrpc\": \"2.0\",\n" +
" \"method\": \"user.login\",\n" +
" \"params\": {\n" +
" \"user\": " + username + ",\n" +
" \"password\": " + password + "\n" +
" },\n" +
" \"id\": 1,\n" +
" \"auth\": null\n" +
"}";
String loginResponse = HttpsUtils.sendByHttp(loginBody, url);
String result = JSON.parseObject(loginResponse).getString("result");
result = "\"" + result + "\"";
return result;
}
java连接zabbix—使用字符串发送请求体
最新推荐文章于 2023-09-11 10:56:07 发布