Create Category
API Description
1、使用子账号创建视频分类
2、接口支持https协议
API URL
http://api.polyv.net/v3/category/add
Request Method
POST
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 | Sub-account appId |
| timestamp | true | Long | Current time in milliseconds, valid for 3 minutes |
| sign | true | String | Signature, 32-character uppercase MD5 value See MD5 signature generation rules |
| name | true | String | Category name |
| parentId | false | String | Parent category ID, defaults to 1 (default category) |
Example
http://api.polyv.net/v3/category/add
Form parameters:
appId=xxxxxx&name=%E6%B5%8B%E8%AF%95%E5%88%9B%E5%BB%BA%E5%88%86%E7%B1%BB&sign=FC67B8973F35D00F9E843C380880DFFD&parentId=1617850424921×tamp=1617850576238
Response Parameters
| Parameter | Type | Description |
|---|---|---|
| code | Integer | Response status code, 200 for success, non-200 for failure See global error description |
| status | String | Response status text |
| error | Object | Returns null on success, returns error description on failure See error parameter description |
| requestId | String | Unique business request ID for troubleshooting |
| data | String | Returns the created category ID on success, returns null on failure |
Error Parameter Description
| Field | Type | Description |
|---|---|---|
| code | Integer | Error code |
| desc | String | Error description |
Java Request Example
For quick integration of basic code, download the relevant dependency source code, click to download source code. After downloading, add it to your project. The test cases include HttpUtil.java and VodSignUtil.java in the downloaded file.
It is strongly recommended to use the VOD Java SDK for API integration. The VOD Java SDK provides unified encapsulation and optimization for API call logic, exception handling, data signing, and HTTP request thread pools.
private static final Logger log = LoggerFactory.getLogger(VodSubAccountTest.class);
/**
* 创建分类
* @throws Exception
* @throws NoSuchAlgorithmException
*/
@Test
public void testSubAddCategory() throws Exception, NoSuchAlgorithmException {
//公共参数,填写自己的实际参数
String appId = super.appId;
String appSecret = super.appSecret;
String timestamp = String.valueOf(System.currentTimeMillis());
//业务参数
String url = "http://api.polyv.net/v3/category/add";
String name = "测试创建分类";
String parentId = "1617850424921";
Map<String, String> requestMap = new HashMap<>();
requestMap.put("appId", appId);
requestMap.put("timestamp", timestamp);
requestMap.put("name", name);
requestMap.put("parentId", parentId);
requestMap.put("sign", VodSignUtil.getSignMd5(requestMap, appSecret));
String response = HttpUtil.postFormBody(url, requestMap);
log.debug("测试创建分类,{}", response);
//do somethings
}
Response Example
For global error descriptions, see Global Error Description
Success Example
{
"requestId": "00543c3f-2d3d-4765-85ca-b332f1021362",
"code": 200,
"status": "success",
"error": null,
"data": 1617850556356
}
Error Example
Timestamp Error
{
"requestId": "5ede3d23-45f0-4661-99be-e95d07daf049",
"code": 400,
"status": "error",
"error": {
"code": 100,
"desc": "invalid timestamp"
},
"data": null
}
Incorrect appId
{
"requestId": "5ede3d23-45f0-4661-99be-e95d07daf049",
"code": 400,
"status": "error",
"error": {
"code": 101,
"desc": "application not exist"
},
"data": null
}
Sub-account does not exist
{
"requestId": "5ede3d23-45f0-4661-99be-e95d07daf049",
"code": 400,
"status": "error",
"error": {
"code": 102,
"desc": "user children not exist"
},
"data": null
}
Sub-account expired
{
"requestId": "5ede3d23-45f0-4661-99be-e95d07daf049",
"code": 403,
"status": "error",
"error": {
"code": 103,
"desc": "user children expired"
},
"data": null
}
Signature error
{
"requestId": "5ede3d23-45f0-4661-99be-e95d07daf049",
"code": 403,
"status": "error",
"error": {
"code": 104,
"desc": "invalid signature"
},
"data": null
}
Insufficient account permissions
{
"requestId": "5ede3d23-45f0-4661-99be-e95d07daf049",
"code": 403,
"status": "error",
"error": {
"code": 105,
"desc": "permission limited"
},
"data": null
}
Category name cannot be empty
{
"requestId": "5ede3d23-45f0-4661-99be-e95d07daf049",
"code": 400,
"status": "error",
"error": {
"code": 3000,
"desc": "没有填写栏目名称"
},
"data": null
}
Parent category cannot be empty
{
"requestId": "5ede3d23-45f0-4661-99be-e95d07daf049",
"code": 400,
"status": "error",
"error": {
"code": 3001,
"desc": "category not exist"
},
"data": null
}
Sub-account does not have permission to create categories in this directory
{
"requestId": "5ede3d23-45f0-4661-99be-e95d07daf049",
"code": 400,
"status": "error",
"error": {
"code": 3002,
"desc": "子账号没有权限在该目录下创建分类"
},
"data": null
}
A video category with the same name already exists
{
"requestId": "df5750d9-27b0-4390-ad7c-f0d1f86d0d14",
"code": 400,
"status": "error",
"error": {
"code": 3003,
"desc": "已存在同名的视频分类"
},
"data": null
}
