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 KitRESTCommentsComments:delete

Comments:delete

Function

Deletes a comment.

Scenario

By calling the Comments.delete API, your app can delete a comment.

Restrictions

  • Only the file creator or comment creator of the writer, commenter, or owner role can delete a comment.
  • 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 DELETE

Direction

Developer server -> HUAWEI Drive server

URL

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

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

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

None.

Request Example

DELETE https://driveapis.cloud.huawei.com.cn/drive/v1/files/AADUyBNACuoBSKfx8gh50-ASp_fyGgrsA/comments/BsFppwNQLSq8YGFfyhbtPY7NmPWFsC0sv HTTP/1.1 
Accept: application/json 
Cache-Control: no-cache 
Authorization: Bearer CF3NTYZSs7MRmxWyj8ssonQQxDgSPAjnDvrf+91NrpN22LdUrMA30A5Kzz0mf55sWao7e7VeLrmjQ0z2OmwPWlt3S00/L1BJppbTFhIgWb74ZBK8CFImUA==

Response Parameters

If successful, this method returns status code 204.

Response Example

None.

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

204

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.

Call Example

    public static void main(String[] args) throws IOException {
        // Set the request URL, file ID, comment ID, and access token.
        String url = "https://driveapis.cloud.huawei.com.cn/drive/v1/files";
        String fileId = "AB0tr6O8DTQAguUs3yPFt3wQ5SDfLg04A";
        String commentId = "BlIuT9Ue4I8qnKGDcmf9MUZf5sCpjOCDK";
        String access_token = "CV5T547SEXpRlyuxqvz+PnRCtnVu784+OEIXmXAafKC+ifA3eJRnM0Ttsv20bJCkrcA+FNi4bU4nKcbERpQxlkMLQ6/Xt1iEQJYrFMyamnnI9JUV+jz4cQ==";
        // Delete a comment.
        Boolean isDelete = false;
        isDelete = commentDelete(url, access_token, fileId, commentId);

        System.out.println(isDelete);
    }

    private static Boolean commentDelete(String url, String access_token, String fileId, String commentId) throws IOException {
        StringBuilder stringBuilder = new StringBuilder("");
        stringBuilder.append("/").append(fileId).append("/").append("comments").append("/").append(commentId);
        HttpDelete httpDelete = new HttpDelete(url + stringBuilder);
        httpDelete.setHeader("Authorization","Bearer " + access_token);

        CloseableHttpResponse response = HttpClientUtil.getClient().execute(httpDelete);

        try {
            if(response.getStatusLine().getStatusCode() == 204){//httpStatus 204 stands for success
                return true;
            }
            return false;
        }finally {
            response.close();
        }
    }
Search in References
Enter a keyword.