Protocol | HTTP POST |
|---|---|
Direction | Developer server -> HUAWEI Drive server |
URL | https://driveapis.cloud.huawei.com.cn/drive/v1/files/{fileId}/comments |
Data Format | Request: Content-Type: application/json Response: Content-Type: application/json |
Parameter | Mandatory/Optional | Type | Description |
|---|---|---|---|
fields | Mandatory | string | Fields in the request, which are in the partial response format. For details, please refer to Overview. |
form | Optional | string | Media format. |
prettyPrint | Optional | boolean | Indicates whether to return a response in a human-readable format. |
quotaId | Optional | string | User identifier, which can contain a maximum of 40 characters. This parameter is used to restrict the maximum number of API calls for a single user. |
callback | Optional | string | Callback function used in JSONP requests. |
Request Header
Parameter | Mandatory/Optional | Type | Description |
|---|---|---|---|
x-hw-trace-id | Optional | string | ID used for service tracing. |
x-hw-app-id | Optional | string | App ID. |
version | Optional | string | SDK version number. |
x-hw-terminal | Optional | string | Device model. |
x-hw-os | Optional | string | Device operating system. |
unionID | Optional | string | User's UnionID. |
User-Agent | Optional | string | App version number or app ID. |
x-hw-deviceUUID | Optional | string | UUID of the device. |
x-hw-deviceUDID | Optional | string | UDID of the device. |
x-hw-appPackageName | Optional | string | App package name. |
x-hw-network | Optional | string | Network type. The options include WiFi, 2G, 3G, 4G, 5G, and wire. |
Request Body
Parameter | Mandatory/Optional | Type | Description |
|---|---|---|---|
description | Mandatory | string | Comment content. |
quotedContent.mimeType | Optional | string | Type of the quoted content. |
quotedContent.content | Optional | string | Quoted content. |
position | Optional | string | Position of the comment content, in JSON format. The JSON string is verified based on the Anchor definition. |
POST https://driveapis.cloud.huawei.com.cn/drive/v1/files/AADUyBNACuoBSKfx8gh50-ASp_fyGgrsA/comments?fields=*? HTTP/1.1 Accept: application/json Cache-Control: no-cache Authorization: Bearer CF3NTYZSs7MRmxWyj8ssonQQxDgSPAjnDvrf+91NrpN22LdUrMA30A5Kzz0mf55sWao7e7VeLrmjQ0z2OmwPWlt3S00/L1BJppbTFhIgWb74ZBK8CFImUA==
When the status code is 200:
Parameter | Type | Description |
|---|---|---|
category | string | Resource type. The value is always drive#comment. |
id | string | Comment ID. |
createdTime | string | Time when the comment is created. |
editedTime | string | Last time when the comment is modified. |
creator.category | string | User type. The value is always drive#user. |
creator.dispalyName | string | Display name of the user. |
creator.profilepPhotoLink | string | Link to the user's profile picture, which is not returned by default. |
creator.me | boolean | Indicates whether the user is the requesting user. |
creator.permissionId | string | Permission ID. |
creator.userAccount | string | Account of the user, which is not returned by default. |
description | string | Content of the comment in plain text format. |
htmlDescription | string | Content of the comment in HTML format. |
deleted | boolean | Indicates whether the comment is deleted. |
resolved | boolean | Indicates whether the comment is resolved. |
quotedContent.mimeType | string | Type of the quoted content. |
quotedContent.content | string | Quoted content. |
position | string | Position of the comment content. |
replies[] | list | List of replies to the comment. |
replies.category | string | Reply type. The value is always drive#reply. |
replies.id | string | Reply ID. |
replies.createdTime | string | Time when the reply is created. |
replies.editedTime | string | Last time when the reply is modified. |
replies.creator.category | string | User type. The value is always drive#user. |
replies.creator.displayName | string | Display name of the user. |
replies.creator.profilePhotoLink | string | Link to the user's profile picture, which is not returned by default. |
replies.creator.me | boolean | Indicates whether the user is the requesting user. |
replies.creator.permissionId | string | Permission ID. |
replies.creator.userAccount | string | Account of the user, which is not returned by default. |
replies.htmlDescription | string | Reply content in HTML format. |
replies.description | string | Reply content. |
replies.deleted | boolean | Indicates whether the reply is deleted. |
replies.operate | string | Operation to be performed for the comment. |
{
"category": "drive#comment",
"id": "string",
"createdTime": "2020-02-19T14:44:40.660Z",
"editedTime": "2020-02-19T14:44:40.661Z",
"creator": {
"category": "drive#user",
"displayName": "string",
"profilePhotoLink": "string",
"me": true,
"permissionId": "string",
"userAccount": "string"
},
"description": "string",
"htmlDescription": "string",
"deleted": true,
"resolved": true,
"quotedContent": {
"mimeType": "string",
"content": "string"
},
"position": "string",
"replies": [
{
"category": "drive#reply",
"id": "string",
"createdTime": "2020-02-19T14:44:40.661Z",
"editedTime": "2020-02-19T14:44:40.661Z",
"creator": {
"category": "drive#user",
"displayName": "string",
"profilePhotoLink": "string",
"me": true,
"permissionId": "string",
"userAccount": "string"
},
"htmlDescription": "string",
"description": "string",
"deleted": true,
"operate": "string"
}
]
} Status Code | Result Code | Response Code | Description |
|---|---|---|---|
200 | NA | - | Success. |
400 | 21004001 | LACK_OF_PARAM | Input parameter is missing. Check the parameter list. |
400 | 21004002 | PARAM_INVALID | Parameter verification failed. Check the parameter list. |
403 | 21004032 | SERVICE_NOT_SUPPORT | The service is not supported. |
403 | 21004035 | INSUFFICIENT_SCOPE | Scope verification failed. |
403 | 21004036 | INSUFFICIENT_PERMISSION | Insufficient role permission. |
500 | 21005006 | SERVER_TEMP_ERROR | Server error. |
403 | 21074033 | AGREEMENT_NOT_SIGNED | The HUAWEI Drive user agreement is not signed. Try again after the agreement is signed. |
403 | 21084031 | DATA_MIGRATINT | The security policy is being updated. Please wait until the update is complete. |
500 | 21085002 | OUTER_SERVICE_UNAVAILABLE | External service is unavailable. |
500 | 21085006 | SERVER_TEMP_ERROR | Server error. |
For details about other result codes, please refer to Status Codes.
public static void main(String[] args) throws IOException {
// Set the request URL, file ID, and access token.
String url = "https://driveapis.cloud.huawei.com.cn/drive/v1/files/";
String fileId = "AB0tr6O8DTQAguUs3yPFt3wQ5SDfLg04A";
String access_token = "CV5T547SEXpRlyuxqvz+PnRCtnVu784+OEIXmXAafKC+ifA3eJRnM0Ttsv20bJCkrcA+FNi4bU4nKcbERpQxlkMLQ6/Xt1iEQJYrFMyamnnI9JUV+jz4cQ==";
// Create a file comment.
JSONObject commentInfo = commentCreateContent(url, access_token, fileId);
System.out.println(commentInfo.toJSONString());
}
private static JSONObject commentCreateContent(String url, String access_token, String fileId) throws IOException {
StringBuilder stringBuilder = new StringBuilder("");
stringBuilder.append(fileId).append("/").append("comments");
stringBuilder.append("?").append("fields=*");
HttpPost httpPost = new HttpPost(url + stringBuilder);
httpPost.setHeader("Authorization", "Bearer " + access_token);
httpPost.setHeader("Content-Type", "application/x-www-form-urlencoded");
httpPost.setHeader("Accept", "application/json");
JSONObject jsonParam = new JSONObject();
jsonParam.put("description", "2020/02/23 11:20");
JSONObject jsonObject = new JSONObject();
jsonObject.put("mimeType", "text/html");
jsonObject.put("content", "2222");
jsonParam.put("quotedContent", jsonObject);
StringEntity entity = new StringEntity(jsonParam.toString());
httpPost.setEntity(entity);
CloseableHttpResponse response = HttpClientUtil.getClient().execute(httpPost);
try {
HttpEntity responseEntity = response.getEntity();
String ret = responseEntity != null ? EntityUtils.toString(responseEntity) : null;
JSONObject jsonObject1 = (JSONObject) JSON.parse(ret);
EntityUtils.consume(responseEntity);
return jsonObject1;
} finally {
response.close();
}
}