Get Application Role Permissions
Updated: 2025-07-17 14:55:09
API Description
1、获取应用角色权限
2、接口支持https协议
API URL
http://api.polyv.net/live/v4/user/webapp-role/get
Request Method
GET
API Constraints
- The API supports both HTTP and HTTPS. HTTPS is recommended for security. API calls have frequency limits. See details
Request Parameters
| Parameter | Required | Type | Description |
|---|---|---|---|
| appId | true | String | Account appId See details: Get Secret Key |
| timestamp | true | Long | Current 13-digit millisecond timestamp, valid for 3 minutes |
| sign | true | String | Signature, a 32-character uppercase MD5 value. The appSecret used to generate the signature is critical for communication data security. It must not be stored or used directly on the client side. All APIs must be called through the customer's own server to relay requests to the POLYV server for response data. See details: Signature Generation Rules |
| roleId | true | Integer | Role ID |
Example
http://api.polyv.net/live/v4/user/webapp-role/get?roleId=1&appId=frlr1zazn3&sign=4D418459FA42A9F88475022E33945955×tamp=1659056102639
Response Parameters
| Parameter | Type | Description |
|---|---|---|
| code | Integer | Status code, same as HTTP status code, used to determine the basic response status |
| status | String | Response result, determined by business logic. Returns success on success, error on failure |
| success | Boolean | Whether the request was successful |
| requestId | String | Request ID, a unique UUID generated for each request. Only used for troubleshooting and debugging, not for business logic |
| error | Object | Error information when status code is not 200 See details: Error Field Description |
| data | Object | Role permission information See details: Data Parameter Description |
Error Parameter Description
| Parameter | Type | Description |
|---|---|---|
| code | Integer | Error code, used to determine the specific error reason |
| desc | String | Error description, corresponding to error.code |
Data Parameter Description
| Parameter | Type | Description |
|---|---|---|
| role | Object | Role information See details: Role Parameter Description |
| permissions | Array | Permission list See details: Permissions Parameter Description |
Role Parameter Description
| Parameter | Type | Description |
|---|---|---|
| id | Integer | Role ID |
| name | String | Role name |
| userId | String | User ID |
| description | String | Role description |
| status | String | Role status |
| createdTime | Long | Creation time (13-digit millisecond timestamp) |
| lastModified | Long | Last modification time (13-digit millisecond timestamp) |
| permissionName | String | Permission name |
| isOldRole | Boolean | Whether it is an old role |
| type | String | Role type (root: visible only to the main account, child: visible to both main and sub-accounts) |
Permissions Parameter Description
| Parameter | Type | Description |
|---|---|---|
| id | Integer | Permission ID |
| type | String | Permission type |
| name | String | Permission name |
| code | String | Permission code |
| parentId | Integer | Parent permission ID |
| lft | Integer | Left node value (for tree structure) |
| rgt | Integer | Right node value (for tree structure) |
| createdTime | Long | Creation time (13-digit millisecond timestamp) |
| lastModified | Long | Last modification time (13-digit millisecond timestamp) |
| depth | Integer | Permission hierarchy depth |
| owned | Boolean | Whether the permission is owned |
Java Request Example
For quick integration of basic code, please download the relevant dependency source code. Click here to download the source code. After downloading, add it to your own source code project. The test cases include HttpUtil.java and LiveSignUtil.java in the downloaded file.
It is strongly recommended to use the Live Java SDK for API integration. The Live Java SDK provides unified packaging and optimization for API call logic, exception handling, data signing, and HTTP request thread pooling.
private static final Logger log = LoggerFactory.getLogger(getClass());
/**
* 获取应用角色权限
* @throws IOException
* @throws NoSuchAlgorithmException
*/
@Test
public void getRoleTest() 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/webapp-role/get";
String roleId = "1";
//http 调用逻辑
Map<String, String> requestMap = new HashMap<>();
requestMap.put("appId", appId);
requestMap.put("timestamp", timestamp);
requestMap.put("roleId", roleId);
requestMap.put("sign", LiveSignUtil.getSign(requestMap, appSecret));
String response = HttpUtil.get(url, requestMap);
log.info("测试获取应用角色权限成功:{}", response);
//do somethings
}
Response Example
For global error descriptions, see Global Error Description
Success Example
{
"code": 200,
"status": "success",
"requestId": "8352399b-d440-4e21-affa-2ea10e734c52",
"data": {
"role": {
"id": 3521,
"name": "测试角色",
"userId": "2b3ccac944",
"description": "这是一个测试角色",
"status": null,
"createdTime": 1752731090000,
"lastModified": 1752731090000,
"permissionName": null,
"isOldRole": null,
"type": "root"
},
"permissions": [
{
"id": 102,
"type": "LIVE_V2",
"name": "直播权限",
"code": "live_v2",
"parentId": 0,
"lft": 1,
"rgt": 310,
"createdTime": 1619769766000,
"lastModified": 1619769766000,
"depth": 0,
"owned": false
},
{
"id": 103,
"type": "LIVE_V2",
"name": "新建直播",
"code": "live-create-channel-center",
"parentId": 1,
"lft": 2,
"rgt": 7,
"createdTime": 1619769799000,
"lastModified": 1678786231000,
"depth": 1,
"owned": false
}
]
},
"success": true
}
Error Example
{
"code": 400,
"status": "error",
"requestId": "d310b70bc329403f87f77f9203d50f89.128.16360831552223589",
"error": {
"code": 20001,
"desc": "角色不存在"
},
"success": false
}
