We use essential cookies for the website to function, as well as analytics cookies for analyzing and creating statistics of the website performance. To agree to the use of analytics cookies, click "Accept All". You can manage your preferences at any time by clicking "Cookie Settings" on the footer. More Information.

Only Essential Cookies
Accept All
ReferencesDrive KitRESTRepliesReplies:create

Replies:create

Function

Creates a reply list.

Scenario

By calling the Replies.create API, your app can create a reply to a comment.

Restrictions

  • Only the writer, commenter, or owner role can create a reply.
  • The value of scope must be one of the following:
    • https://www.huawei.com/auth/drive.file
    • https://www.huawei.com/auth/drive

Prototype

Protocol

HTTP POST

Direction

Developer server -> HUAWEI Drive server

URL

https://driveapis.cloud.huawei.com.cn/drive/v1/files/{fileId}/comments/{commentId}/replies

Data Format

Request: Content-Type: application/json

Response: Content-Type: application/json

Path Parameters

Expand

Parameter

Mandatory/Optional

Type

Description

fileId

Mandatory

string

File ID.

commentId

Mandatory

string

Comment ID.

Query Parameters

Expand

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 Parameters

Request Header

Expand

Parameter

Mandatory/Optional

Type

Description

Authorization

Mandatory

string

User authorization information, that is, the access token (AT).

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

Expand

Parameter

Mandatory/Optional

Type

Description

description

Optional

string

Reply content.

operate

Optional

string

Operation to be performed for the comment.

Request Example

Collapse
Word wrap
Dark theme
Copy code
  1. POST https://driveapis.cloud.huawei.com.cn/drive/v1/files/AAAB9Wn0DTQCIqPbW9avGjAQo9dbxg04A/comments/BkytC_85-y5hoiLxCRnNCHZcDynNC_siY/replies?fields=* HTTP/1.1
  2. Accept: application/json
  3. Content-Type: application/x-www-form-urlencoded
  4. Authorization: Bearer CV3PnPLZXyr9K2GV7RYZkF962JZvoEkMQhTho3QHQAPQUyma/lEyZskP/IMWrc7FvaeHivO7y0lyibI/fQvulBnTgtXArSVPsjaLKvYNkDsJSaIR2/sx+K40bYDWWpKFvJNKg2U47jRwz2mfiF3ortNk
  5. Cache-Control: no-cache
  6. {
  7. "description":"HuaweiTest001",
  8. "operate":"reopen"
  9. }

Response Parameters

When the status code is 200:

Expand

Parameter

Type

Description

category

string

Resource type. The value is always drive#reply.

id

string

Reply ID.

createdTime

string

Time when the reply is created.

editedTime

string

Last time when the reply is modified.

creator.category

string

User type. The value is always drive#user.

creator.displayName

string

Display name of the user.

creator.profilePhotoLink

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.

htmlDescription

string

Reply content in HTML format.

description

string

Reply content.

deleted

boolean

Indicates whether the reply is deleted.

operate

string

Operation to be performed for the comment.

Response Example

Collapse
Word wrap
Dark theme
Copy code
  1. {
  2. "creator": {
  3. "permissionId": "299639512454136576",
  4. "displayName": "*******3121@**3.com",
  5. "me": true,
  6. "category": "drive#user"
  7. },
  8. "editedTime": "2020-02-19T13:49:32.862Z",
  9. "operate": "reopen",
  10. "deleted": false,
  11. "createdTime": "2020-02-19T13:49:32.862Z",
  12. "description": "HuaweiTest001",
  13. "id": "BpMy9fyvWDfDM2rRKzfpNbqDkNfOnVg7w",
  14. "category": "drive#reply",
  15. "htmlDescription": "HuaweiTest001"
  16. }

Common Result Codes

The last four digits in the result code indicate the service error code, which is used to differentiate error scenarios. For details about other service error codes, please refer to Status Codes.

Expand

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.

404

21084041

CONTENT_NOT_FOUND

No resources found.

500

21085002

OUTER_SERVICE_UNAVAILABLE

Server error.

500

21085006

SERVER_TEMP_ERROR

Server error.

403

21094038

OUTER_SERVICE_ERROR

Server error.

Call Example

Collapse
Word wrap
Dark theme
Copy code
  1. public static void main(String[] args) throws IOException {
  2. // Set the request URL, file ID, comment ID, and access token.
  3. String url = "https://driveapis.cloud.huawei.com.cn/drive/v1/files/";
  4. String fileId = "AB0tr6O8DTQAguUs3yPFt3wQ5SDfLg04A";
  5. String commentId = "BlIuT9Ue4I8qnKGDcmf9MUZf5sCpjOCDK";
  6. String access_token = "CV5T547SEXpRlyuxqvz+PnRCtnVu784+OEIXmXAafKC+ifA3eJRnM0Ttsv20bJCkrcA+FNi4bU4nKcbERpQxlkMLQ6/Xt1iEQJYrFMyamnnI9JUV+jz4cQ==";
  7. // Create a reply to a comment.
  8. JSONObject replyInfo = replyCreate(url, access_token, fileId, commentId);
  9. System.out.println(replyInfo.toJSONString());
  10. }
  11. private static JSONObject replyCreate(String url, String access_token, String fileId, String commentId) throws IOException {
  12. StringBuilder stringBuilder = new StringBuilder("");
  13. stringBuilder.append(fileId).append("/").append("comments").append("/").append(commentId).append("/").append("replies");
  14. stringBuilder.append("?").append("fields=*");
  15. HttpPost httpPost = new HttpPost(url + stringBuilder);
  16. httpPost.setHeader("Authorization","Bearer " + access_token);
  17. httpPost.setHeader("Content-Type", "application/x-www-form-urlencoded");
  18. httpPost.setHeader("Accept", "application/json");
  19. JSONObject jsonParam = new JSONObject();
  20. jsonParam.put("description", "HuaweiTest001");
  21. jsonParam.put("operate", "reopen");
  22. StringEntity entity = new StringEntity(jsonParam.toString());
  23. httpPost.setEntity(entity);
  24. CloseableHttpResponse response = HttpClientUtil.getClient().execute(httpPost);
  25. try {
  26. HttpEntity responseEntity = response.getEntity();
  27. String ret = responseEntity != null ? EntityUtils.toString(responseEntity) : null;
  28. JSONObject jsonObject = (JSONObject) JSON.parse(ret);
  29. EntityUtils.consume(responseEntity);
  30. return jsonObject;
  31. }finally {
  32. response.close();
  33. }
  34. }
Search in References
Enter a keyword.