By calling the Changes.getStartCursor API, your app can obtain the starting cursor required by the Changes.subscribe API.
Protocol | HTTP GET |
|---|---|
Direction | Developer server -> HUAWEI Drive server |
URL | https://driveapis.cloud.huawei.com.cn/drive/v1/changes/getStartCursor |
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
None.
GET https://driveapis.cloud.huawei.com.cn/drive/v1/changes/getStartCursor?fields=* HTTP/1.1 Content-Type: application/json Authorization: Bearer CV3PnPLZXyr9K2GV7RYZkF962JZvoEkMQhTho3QHQAPQUyma/lEyZskP/IMWrc7FvaeHivO7y0lyibI/fQvulBnTgtXArSVPsjaLKvYNkDsJSaIR2/sx+K40bYDWWpKFvJNKg2U47jRwz2mfiF3ortNk Cache-Control: no-cache
When the status code is 200:
Parameter | Type | Description |
|---|---|---|
category | string | Resource type. The value is always drive#startCursor. |
startCursor | string | Starting cursor. |
Status Code | Result Code | Response Code | Description |
|---|---|---|---|
200 | NA | - | Success. |
500 | 21055002 | OUTER_SERVICE_UNAVAILABLE | External service is unavailable. |
500 | 21005006 | SERVER_TEMP_ERROR | Temporary server error. |
403 | 21074033 | AGREEMENT_NOT_SIGNED | The HUAWEI Drive user agreement is not signed. Try again after the agreement is signed. |
For details about other result codes, please refer to Status Codes.
public static void main(String[] args) throws IOException {
// Set the request URL and access token.
String url = "https://driveapis.cloud.huawei.com.cn/drive/v1/changes/getStartCursor";
String access_token = "CV5OUVN/e79TSba9Kaxlgx+TONKyYovWvre8BZM05oh6J51jBIbeYp0FRSuLcFBZoDaft0V/B+m+mPFf7MG3n8JmO8w3n6/K6zUI8I5/auSzdxv8GOdAPw==";
// Obtain the starting cursor.
JSONObject cursorInfo = changesGetStartCursor(url, access_token);
System.out.println(cursorInfo.toJSONString());
}
private static JSONObject changesGetStartCursor(String url, String access_token) throws IOException {
StringBuilder stringBuilder = new StringBuilder("");
stringBuilder.append("?").append("fields=*");
HttpGet httpGet = new HttpGet(url + stringBuilder);
httpGet.setHeader("Authorization","Bearer " + access_token);
CloseableHttpResponse response = HttpClientUtil.getClient().execute(httpGet);
try {
HttpEntity responseEntity = response.getEntity();
String ret = responseEntity != null ? EntityUtils.toString(responseEntity) : null;
JSONObject jsonObject = (JSONObject) JSON.parse(ret);
EntityUtils.consume(responseEntity);
return jsonObject;
}finally {
response.close();
}
}