Description
COS allows you to query tags of an existing bucket. The GET Bucket tagging API is used to query existing bucket tags under a specified bucket.
Note:
If you are using a sub-account to call this API, please ensure that you have obtained permission for GET Bucket tagging from the root account.
Request
Request Example
GET /?tagging HTTP 1.1
Host:<BucketName-APPID>.<Endpoint>
Date: GMT Date
Authorization: Auth String
Note:
Authorization: Auth String (For details, see Request Signature documentation).
Request Header
This API only uses common request headers. For details, see Common Request Headers documentation.
Request Body
The request body of this request is empty.
Response
Response Headers
This API only returns the public response header. For details, see Common Response Headers documentation.
Response Body
Upon successful query, returns application/xml data containing existing tag information for the bucket.
<Tagging>
<TagSet>
<Tag>
<Key>string</Key>
<Value>string</Value>
</Tag>
<Tag>
<Key>string</Key>
<Value>string</Value>
</Tag>
</TagSet>
</Tagging>
Specific node descriptions are as follows:
| Node Name (Keyword) | Parent Node | Description | Type |
|---|---|---|---|
| Tagging | No | Tag Set | Container |
| TagSet | Tagging | Tag Set | Container |
| Tag | Tagging.TagSet | Tag Set, supporting up to 50 tags | Containers |
| Key | Tagging.TagSet.Tag | Tag Key, with a length not exceeding 128 bytes, supporting English letters, digits, spaces, plus signs, hyphens, underscores, equal signs, periods, colons, and slashes. | String |
| Value | Tagging.TagSet.Tag | Tag Value, with a length not exceeding 256 bytes, supporting English letters, digits, spaces, plus signs, hyphens, underscores, equal signs, periods, colons, and slashes. | String |
Error Code
The following describes some special but common errors that may occur with this request:
| Error Code | Description | HTTP Status Code |
|---|---|---|
| SignatureDoesNotMatch | If this error code is returned, it means the provided signature is incorrect. | 403 Forbidden |
| NoSuchBucket | If this error code is returned, it means the bucket you want to add the rule to is not found. | 404 Not Found |
| NoSuchTagSetError | The bucket requested does not have any bucket tags set. | 404 Not Found |
Practical Case
Request
The following request applies to query tag information under the bucket examplebucket-1250000000. COS parses this request and returns the existing tags {age:18} and {name:John Doe} under the bucket.
GET /?tagging HTTP/1.1
User-Agent: curl/7.29.0
Accept: */*
Host: examplebucket-1250000000.cos.city.yfm4.fsphere.cn
Authorization: q-sign-algorithm=sha1&q-ak=AKIDxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx&q-sign-time=1516361923;1517361973&q-key-time=1516361923;1517361973&q-url-param-list=tagging&q-header-list=content-md5;host&q-signature=71251feb4501494edcfbd01747fa873003759404
Content-Length: 127
Content-Type: application/xml
Response
HTTP/1.1 200 OK
Content-Type: application/xml
Connection: close
Date: Fri, 19 Jan 2018 11:40:22 GMT
<Tagging>
<TagSet>
<Tag>
<Key>age</Key>
<Value>18</Value>
</Tag>
<Tag>
<Key>name</Key>
<Value>John Doe</Value>
</Tag>
</TagSet>
</Tagging>