String url = Constant.ADDFUNCTION.replace("HOST", domainhost);
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
String token = ((OAuth2AuthenticationDetails) authentication.getDetails()).getTokenValue();
MultipartBody requestBody = Unirest.post(url)
.header("accept", "application/json")
.header("Authorization", "Bearer " + token)
// .field("functionId", menu.getId())
.field("showOrder", menu.getShoworder().toString())
.field("name", menu.getText())
.field("appCode", APP_CODE)
.field("tenantCode", TENANT_CODE)
.field("parentId", menu.getParentCode())
.field("extend", "")
.field("i18nkey", "")
.field("type", "menu")
.field("isDisabled", "0")
.field("accessType", "private")
.field("openMode", "self")
.field("isCached", "0")
.field("isShowFunction", "1")
.field("isChildRoute", "0")
.field("remark", "")
.field("url", "")
// .field("userAuthority",jsonObject.get("userAuthority").toString())
// .field("extendProperties",jsonObject.get("extendProperties").toString())
.field("categoryId", "");
HttpResponse<String> response = requestBody.asString();
String body = response.getBody();
JSONObject jsonObj = JSONObject.parseObject(body);
if (response.getStatus() == 200 && jsonObj.get("code").equals("success")) {
System.out.println("Response Body: " + response.getBody());
return jsonObj.get("data").toString();
} else {
System.out.println("Status: " + response.getStatus());
System.out.println("Error Body: " + response.getBody());
throw new RuntimeException("用户中心修改异常!" + "URL为" + url + "body为" + menu + "异常信息为" + jsonObj.get("msg"));
}
http请求 参数为form-data格式
最新推荐文章于 2024-07-31 04:30:38 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)