如下


	JSONObject jsonObject = new JSONObject();
	jsonObject.put("clientId", clientId);
	jsonObject.put("secret", SecureUtil.md5(secret));
	jsonObject.put("userId", userId);
	
	Map<String, String > heads = new HashMap<>();
	heads.put("Content-Type", "application/json;charset=UTF-8");
	
	String result = HttpRequest.post(userRoleUrl)
		.headerMap(heads, false)
		.body(jsonObject.toJSONString()).timeout(30*1000).execute().body();
		


	JSONObject json = new JSONObject();
	json.put("code", config.getCode());
	json.put("pass", config.getPass());
	
	String result = HttpRequest.post(config.getUrlPersonal())
		.header("Content-Type", "application/x-www-form-urlencoded").form(json).execute().body();
		

官方例子:https://hutool.cn/docs/#/http/Http%E8%AF%B7%E6%B1%82-HttpRequest

Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐