GetObjectTagging
Queries the tags of an object.
About versioning
By default, when you call the GetObjectTagging operation, only the tags of the current version of the object are returned. You can specify the versionId parameter to query the tags of a specified version of the object. If the specified version of the object is a delete marker, OSS returns 404 Not Found.
Request syntax
GET /objectname?tagging
Host: BucketName.oss-cn-hangzhou.aliyuncs.com
Date: Wed, 20 Mar 2019 02:02:36 GMT
Authorization: SignatureValueRequest parameters
| Parameter | Type | Required | Description |
| tagging | String | Yes | The subresource that identifies this as a tagging operation. |
| versionId | String | No | The version ID of the object. If not specified, the tags of the current version are returned. If the specified version is a delete marker, OSS returns 404 Not Found. |
When you call this operation in OSS on Cloud Box, you need to replace the Host with the CloudBox endpoints. For more information, see CloudBox endpoints。
Request headers
All headers in a GetObjectTagging request are common request headers. For more information, seeCommon request headers.
Response headers
The response to a GetObjectTagging request includes common response headers. For more information, seeCommon response headers.
When you query the tags of a specific object version, the response also includes the x-oss-version-id header.
Response elements
| Name | Type | Description |
| Tagging | Container | The root container for the tagging response. Child nodes: TagSet |
| TagSet | Container | The container that holds all tags. Parent nodes: Tagging Child nodes: Tag |
| Tag | Container | A single tag. Parent nodes: TagSet Child nodes: Key and Value |
| Key | String | The key of the tag. Parent nodes: Tag Child nodes: none |
| Value | String | The value of the tag. Parent nodes: Tag Child nodes: none |
Examples
When versioning is not enabled
In this example, a GET request is sent to query the tags of the object objectname in the bucket bucketname. The tags {a:1} and {b:2} are returned with a 200 (OK) status code.
Sample request
GET /objectname?tagging
Host: BucketName.oss-cn-hangzhou.aliyuncs.com
Date: Wed, 20 Mar 2019 02:02:36 GMT
Authorization: OSS4-HMAC-SHA256 Credential=LTAI********************/20250417/cn-hangzhou/oss/aliyun_v4_request,Signature=a7c3554c729d71929e0b84489addee6b2e8d5cb48595adfc51868c299c0c218eSample response
200 (OK)
content-length: 209
server: AliyunOSS
x-oss-request-id: 5C919F38461FB4282600****
date: Wed, 20 Mar 2019 02:02:32 GMT
content-type: application/xml
<?xml version="1.0" encoding="UTF-8"?>
<Tagging>
<TagSet>
<Tag>
<Key>a</Key>
<Value>1</Value>
</Tag>
<Tag>
<Key>b</Key>
<Value>2</Value>
</Tag>
</TagSet>
</Tagging>When versioning is enabled
In this example, a GET request is sent to query the tags of a specific version of the object objectname in the bucket bucketname. The versionId is specified in the sample request. The tag {age:18} is returned with a 200 (OK) status code.
Sample request
GET /objectname?tagging&versionId=CAEQExiBgID.jImWlxciIDQ2ZjgwODIyNDk5MTRhNzBiYmQwYTZkMTYzZjM0****
Host: BucketName.oss-cn-hangzhou.aliyuncs.com
Date: Wed, 24 Jun 2020 08:50:28 GMT
Authorization: OSS4-HMAC-SHA256 Credential=LTAI********************/20250417/cn-hangzhou/oss/aliyun_v4_request,Signature=a7c3554c729d71929e0b84489addee6b2e8d5cb48595adfc51868c299c0c218eSample response
200 (OK)
content-length: 161
server: AliyunOSS
x-oss-request-id: 5EF313D44506783438F3****
date: Wed, 24 Jun 2020 08:50:28 GMT
content-type: application/xml
x-oss-version-id: CAEQExiBgID.jImWlxciIDQ2ZjgwODIyNDk5MTRhNzBiYmQwYTZkMTYzZjM0****
<?xml version="1.0" encoding="UTF-8"?>
<Tagging>
<TagSet>
<Tag>
<Key>age</Key>
<Value>18</Value>
</Tag>
</TagSet>
</Tagging>OSS SDKs
SDK samples for the GetObjectTagging operation are available for the following programming languages:
ossutil command-line tool
For information about the ossutil command that corresponds to the GetObjectTagging operation, seeGetObjectTagging.