目录

HistoryVersions:delete

Function

Deletes a historical file version.

Scenario

By calling the HistoryVersions.delete API, your app can delete a historical file version.

Restrictions

Prototype

Protocol

HTTP DELETE

Direction

Developer server -> HUAWEI Drive server

URL

https://driveapis.cloud.huawei.com.cn/drive/v1/files/{fileId}/historyVersions/{historyVersionId}

Data Format

Request: Content-Type: application/json

Response: Content-Type: application/json

Path Parameters

Parameter

Mandatory/Optional

Type

Description

fileId

Mandatory

string

File ID.

historyVersionId

Mandatory

string

ID of a historical version.

Query Parameters

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.

Request Parameters

Request Header

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/BgZ_uIemYqVW0WYk0eNtKVYLMryFlmKjV/historyVersions/362297555238797056.362297555238797057?fields=* HTTP/1.1
Accept: application/json
Authorization: Bearer
CgB6e3x9Bjh6m9tm8OB0GXjeMWk0m4pVnLmwteDNWXOKPhh0/tjwtIy6Q+OscvD7zhdrElYD0Rak6xA7dI4BM3GSQTuUgFK6ZwFk7K/fjJS5vB7JFmV3
Cache-Control: no-cache

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.

Status Code

Result Code

Response Code

Description

204

NA

  

Success.

400

21004002

PARAM_INVALID

Invalid input parameter. Check the parameter list.

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.

403

21084038

OUTER_SERVICE_ERROR

External service error.

403

21094038

OUTER_SERVICE_ERROR

External service error.

500

21085002

OUTER_SERVICE_UNAVAILABLE

External service is unavailable.

Call Example

	public static void main(String[] args) throws IOException {
        // Set the request URL, file ID, historical version ID, and access token.
        String url = "https://driveapis.cloud.huawei.com.cn/drive/v1/files";
        String fileId = "AAAKRiCEAIYCkUs1zhVB9ewNSzPOGACAA"; // Your own fileId
        String historyVersionId = "367254548466646784.367254548466646785"; // You can get it from HistoryVersionsList interface
        String access_token = "CF3mUGa6TSGM6Ww/9ZwVJ6F2FveRf9CgS38Qm4HAA/cRD8dcD301bo0Bv+FH3Fq/h2X3G8no4w+Qs5BciDzU3ZWyVPKh8eFIJa7a7RyBtjCZhX1WB4vLPw==";
        // Delete a historical version of a file.
        Boolean isDelete = false;
        isDelete = historyVersionsDelete(url, access_token, fileId, historyVersionId);

        System.out.println(isDelete);
    }

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

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

        try {
            System.out.println(response.getStatusLine().getStatusCode());
            // httpstatus 204 stands for success
            if(response.getStatusLine().getStatusCode() == 204){
                return true;
            }
            return false;
        }finally {
            response.close();
        }
    }