| 承载协议 | HTTP GET |
|---|---|
| 接口方向 | 开发者服务器->华为云空间服务器 |
| 接口URL | https://driveapis.cloud.huawei.com.cn/drive/v1/about |
| 数据格式 | 请求消息:Content-Type: application/json 响应消息:Content-Type: application/json |
| 参数 | 是否必选 | 参数类型 | 描述 |
|---|---|---|---|
| fields | 是 | string | 采用[Partial-response格式],具体使用见公共说明。 |
| form | 否 | string | 媒体格式。 |
| prettyPrint | 否 | boolean | 是否以美观格式输出。 |
| quotaId | 否 | string | 用户标识,小于40个字符。用于限制单个用户的API访问数量。 |
| callback | 否 | string | JSONP的callback函数。 |
Request Header
| 参数 | 是否必选 | 参数类型 | 描述 |
|---|---|---|---|
| Authorization | 是 | string | 用户鉴权信息 AccessToken(即AT) |
| x-hw-trace-id | 否 | string | 业务跟踪id。 |
| x-hw-app-id | 否 | string | 应用的appid。 |
| version | 否 | string | SDK版本。 |
| x-hw-terminal | 否 | string | 终端型号。 |
| x-hw-os | 否 | string | 终端操作系统类型。 |
| unionID | 否 | string | 用户的unionID。 |
| User-Agent | 否 | string | 应用版本号/appid。 |
| x-hw-deviceUUID | 否 | string | 设备UUID。 |
| x-hw-deviceUDID | 否 | string | 设备UDID。 |
| x-hw-appPackageName | 否 | string | 应用包名。 |
| x-hw-network | 否 | string | 网络类型,[WiFi, 2G, 3G, 4G, 5G, wire]。 |
Request Body
无
GET https://driveapis.cloud.huawei.com.cn/drive/v1/about?fields=* HTTP/1.1 Accept: application/json Cache-Control: no-cache Authorization: Bearer CF3NTYZSs7MRmxWyj8ssonQQxDgSPAjnDvrf+91NrpN22LdUrMA30A5Kzz0mf55sWao7e7VeLrmjQ0z2OmwPWlt3S00/L1BJppbTFhIgWb74ZBK8CFImUA==
状态码为200时:
| 参数 | 参数类型 | 描述 |
|---|---|---|
| category | string | 资源类型,固定为drive#about。 |
| dataVersion | string | v1.0表示vfs,v2.0表示数据管理服务。 |
| user.category | string | 类型,固定为drive#user。 |
| user.displayName | string | 用户显示名。 |
| user.profilePhotoLink | string | 用户头像链接(默认不返回)。 |
| user.me | boolean | 是否是我。 |
| user.permissionId | string | 权限id。 |
| user.userAccount | string | 帐号名称(默认不返回)。 |
| storageQuota.userCapacity | string | 总容量。 |
| storageQuota.usedSpace | string | 已用容量。 |
| maxFileUploadSize | string | 允许上传的最大文件大小。 |
| maxThumbnailSize | integer | 支持的最大缩略图大小。 |
| domain | string | 本站点域名。 |
| needUpdate | boolean | 用户是否需要进行安全策略更新。 |
| updateUrl | string | 安全策略更新提示页面。 |
| folderLevel | integer | 支持目录的层级。 |
{
"storageQuota":{
"usedSpace":"1458200675",
"userCapacity":"5368709120"
},
"maxThumbnailSize":2097152,
"needUpdate":false, // 值为true,表示需要用户更新安全策略
"maxFileUploadSize":"53687091200",
"domain":"driveapis.cloud.huawei.com.cn",
"category":"drive#about",
"user":{
"permissionId":"233228122990838144",
"displayName":"huaweiExample",
"me":true,
"category":"drive#user"
},
"folderLevel":10
} 错误码后4位为业务错误码,用于区分错误场景,其他业务错误码见状态码章节。
| 状态码 | 错误码 | 响应代码 | 描述 |
|---|---|---|---|
| 200 | NA | - | 成功。 |
| 400 | 21004001 | LACK_OF_PARAM | 缺少入参,请检查参数列表。 |
| 400 | 21004002 | PARAM_INVALID | 参数校验失败,请检查参数列表。 |
| 403 | 21074033 | AGREEMENT_NOT_SIGNED | 用户还未签署华为云空间用户协议,请签署协议后再进行重试。 |
| 403 | 21004032 | SERVICE_NOT_SIPPORT | 服务在当前国家/地区不支持。 |
| 403 | 21084031 | DATA_MIGRATING | 正处于安全策略更新。请等待安全策略更新完成。 |
| 500 | 21055002 | OUTER_SERVICE_UNAVAILABLE | 外部服务不可用。 |
| 500 | 21085006 | SERVER_TEMP_ERROR | 服务器异常。 |
public static void main(String[] args) throws IOException{
// 设置请求地址和用户认证令牌
String url = "https://driveapis.cloud.huawei.com.cn/drive/v1/about";
String access_token = "CV6doD3HkAi7SGjrrWsDZDz0wkko0EQrWZDQKUZNZ/Sw8jytLWm5G1jQS3NtYF+wIWYCG9m3rVROTwg+8xpG6Jq55F0JDbxumn3/7SeatibxOh3sMbNgew==";
// 获取用户信息
JSONObject aboutInfo = aboutGet(url, access_token);
System.out.println(aboutInfo.toJSONString());
}
private static JSONObject aboutGet(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();
}
}