You can call this operation to query the object tags.

Versioning

By default, the GetObjectTagging operation is called to query the tags of the current version of an object. If the current version of the object is a delete marker, OSS returns 404 Not Found. You can query the tags of a specified version of an object by specifying the versionId parameter.

Request structure

GET /objectname? tagging
Host: bucketname.oss‐cn‐hangzhou.aliyuncs.com
Date: GMT Date
Authorization: SignatureValue

Response elements

Element Type Description
Tagging Container The collection of tags.

Child nodes: TagSet

TagSet Container The collection of tags.

Parent nodes: Tagging

Child nodes: Tag

Tag Container The collection of tags.

Parent nodes: TagSet

Child nodes: Key and Value

Key String The key of the object tag.

Parent nodes: Tag

Child nodes: none

Value String The value of the object tag.

Parent nodes: Tag

Child nodes: none

Examples

  • Sample requests for objects in an unversioned bucket

    objectname is contained in bucketname that is unversioned. When you send a GET request to query the tags of objectname, {a:1} and {b:2} are obtained. After the two object tags are obtained, 200 OK is returned.

    GET /objectname? tagging
    Host: bucketname.oss‐cn‐hangzhou.aliyuncs.com
    Date: Wed, 20 Mar 2019 02:02:36 GMT
    Authorization: OSS ************:********************

    Sample success responses

    200 (OK)
    content‐length: 209
    server: AliyunOSS
    x‐oss‐request‐id: 5C919F38461FB42826000002
    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>
  • Sample requests for objects in a versioned bucket

    objectname is contained in bucketname that is versioned. When you specify versionId in a GET request to query the tags of objectname, {age:18} is obtained. After the tag of the specified version of the object is obtained, 200 OK is returned.

    GET /objectname? tagging&versionId=CAEQExiBgID.jImWlxciIDQ2ZjgwODIyNDk5MTRhNzBiYmQwYTZkMTYzZjM0****
    Host: bucketname.oss-cn-hangzhou.aliyuncs.com
    Date: Wed, 24 Jun 2020 08:50:28 GMT
    Authorization: OSS ************:********************

    Sample success responses

    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>

SDKs

You can call GetObjectTagging by using the following OSS SDKs for different programming languages: