1、组织架构新增子节点(排在第一位)
2、(timestamp, appId)参与sign签名,并和sign一起通过url传递,请求体参数不参与签名,通过post请求体传递【请设置请求头contentType:application/json】
3、接口支持https协议
http://api.polyv.net/live/v4/user/organization/create
http://api.polyv.net/live/v4/user/organization/create?appId=frlr1zazn3&sign=012332FBD8DBCFC068AFCB484A2ADECB×tamp=1670550787318
{
"parentId": "2730",
"name": "测试部门",
"description":"负责以解决客户业务测试问题为目的的测试解决方案架构和研发工作"
}
强烈建议您使用直播Java SDK完成API的功能对接,直播Java SDK 对API调用逻辑、异常处理、数据签名、HTTP请求线程池进行了统一封装和优化。
private final Logger log = LoggerFactory.getLogger(getClass());
/**
* 新增组织
* @throws IOException
* @throws NoSuchAlgorithmException
*/
@Test
public void createOrganizationTest() throws IOException, NoSuchAlgorithmException {
//公共参数,填写自己的实际参数
String appId = super.appId;
String appSecret = super.appSecret;
String timestamp = String.valueOf(System.currentTimeMillis());
//业务参数
String url = "http://api.polyv.net/live/v4/user/organization/create";
String parentId = "2730";
String name = "测试部门";
String description = "负责以解决客户业务测试问题为目的的测试解决方案架构和研发工作";
//http 调用逻辑
Map<String, String> requestMap = new HashMap<>();
requestMap.put("appId", appId);
requestMap.put("timestamp", timestamp);
Map<String, Object> jsonMap = new HashMap<>();
jsonMap.put("parentId", parentId);
jsonMap.put("name", name);
jsonMap.put("description", description);
requestMap.put("sign", LiveSignUtil.getSign(requestMap, appSecret));
url = HttpUtil.appendUrl(url, requestMap);
String response = HttpUtil.postJsonBody(url, JSON.toJSONString(jsonMap), null);
log.info("测试新增组织成功:{}", response);
//do somethings
}
{
"code": 200,
"status": "success",
"requestId": "78de516b69364aeabe7d080e7228cc5c.77.16705507903976231",
"data": {
"userId": "1b448be323",
"id": 2757,
"lft": 3,
"rgt": 4,
"parentId": 2,
"name": "测试部门",
"icon": null,
"description": "负责以解决客户业务测试问题为目的的测试解决方案架构和研发工作"
},
"success": true
}
{
"code": 400,
"status": "error",
"requestId": "d310b70bc329403f87f77f9203d50f89.128.16360831552223589",
"error": {
"code": 20001,
"desc": "application not found."
},
"success": false
}