Queries the tags of a resource.

Usage notes

When you call the ListTagResources operation, you must include at least one of the following parameters in the request: Tag.N.Key and ResourceId.N. You can specify a resource ID to query all tags of the resource. You can also specify a tag key to query the tag value and the resource to which the tag is added.

  • If you set the Tag.N.Key parameter to a tag key in the request, you can obtain the tag value based on the Tag.N.Value parameter and the ID of the resource to which the tag is added based on the ResourceId.N parameter.
  • If you set the ResourceId.N parameter to a resource ID in the request, you can obtain the following information about all tags of the specified resource: the tag key indicated by the Tag.N.Key parameter and the tag value indicated by the Tag.N.Value parameter.

QPS limit

A user can perform a maximum of 10 queries per second (QPS). When the number of calls to this operation per second exceeds the QPS limit, throttling is triggered. If throttling is triggered, your business may be affected. We recommend that you take note of the QPS limit on this operation. For more information, see QPS limit.

Authorization information

By default, only Alibaba Cloud accounts can call this operation. RAM users can call this operation only after these RAM users are granted related permissions. The following table describes the authorization information of this operation. For more information, see Policies and examples.

Operation

Action

Resource

ListTagResources

mq:ListTagResources

acs:mq:*:*:*

Request parameters

Parameter Type Required Example Description
Action String Yes ListTagResources

The operation that you want to perform. Set the value to ListTagResources.

InstanceId String No MQ_INST_188077086902****_BXSuW61e

The ID of the instance to which the resource whose tags you want to query belongs.

Note To query the tags of a topic or group, you must specify this parameter.
ResourceType String Yes TOPIC

The type of the resource whose tags you want to query. Valid values:

  • INSTANCE
  • TOPIC
  • GROUP
NextToken String No caeba0****be03f84eb48b699f0a4883

The token that is used to query the next page.

Tag.N.Key String No CartService

The key of tag N added to the resource.

  • Valid values of N: 1 to 20.
  • If you include this parameter in the request, the parameter value cannot be an empty string.
  • The tag key can be up to 128 characters in length and cannot start with acs: or aliyun. It cannot contain http:// or https://.
Tag.N.Value String No ServiceA

The value of tag N added to the resource.

  • Valid values of N: 1 to 20.
  • If you include this parameter in the request, the parameter value can be an empty string.
  • The tag value can be up to 128 characters in length and cannot start with acs: or aliyun. It cannot contain http:// or https://.
ResourceId.N String No test

The ID of the resource whose tags you want to query.

  • If the resource is a Message Queue for Apache RocketMQ instance, set this parameter to the ID of the instance.
  • If the resource is a topic, set this parameter to the name of the topic.
  • If the resource is a group, set this parameter to the ID of the group.

Response parameters

Parameter Type Example Description
NextToken String caeba0****be03f84eb48b699f0a4883

The token returned to query the next page.

RequestId String 301D2CBE-66F8-403D-AEC0-82582478****

The ID of the request. This is a common parameter. Each request has a unique ID. This facilitates troubleshooting and fault locating.

TagResources Array of TagResource

The returned collection of resources and tags, including the resource ID, resource type, and key-value pairs of the tags.

ResourceType String ALIYUN::MQ::TOPIC

The type of the resource whose tags were queried. Valid values:

  • ALIYUN::MQ::INSTANCE
  • ALIYUN::MQ::TOPIC
  • ALIYUN::MQ::GROUP
InstanceId String MQ_INST_188077086902****_BXSuW61e

The ID of the instance.

TagValue String ServiceA

The value of the tag.

ResourceId String TopicA

The ID of the resource.

TagKey String CartService

The key of the tag.

Examples

Sample requests

http(s)://ons.cn-hangzhou.aliyuncs.com/?Action=ListTagResources
&ResourceType=TOPIC
&ResourceId.1=TopicA
&InstanceId=MQ_INST_188077086902****_BXSuW61e
&<Common request parameters>

Sample success responses

XML format

HTTP/1.1 200 OK
Content-Type:application/xml

<ListTagResourcesResponse>
<RequestId>301D2CBE-66F8-403D-AEC0-82582478****</RequestId>
<NextToken>caeba0****be03f84eb48b699f0a4883</NextToken>
<TagResources>
    <ResourceId>TopicA</ResourceId>
    <InstanceId>MQ_INST_188077086902****_BXSuW61e</InstanceId>
    <TagKey>CartService</TagKey>
    <ResourceType>ALIYUN::MQ::TOPIC</ResourceType>
    <TagValue>ServiceA</TagValue>
</TagResources>
</ListTagResourcesResponse>

JSON format

HTTP/1.1 200 OK
Content-Type:application/json

{
  "RequestId" : "301D2CBE-66F8-403D-AEC0-82582478****",
  "NextToken" : "caeba0****be03f84eb48b699f0a4883",
  "TagResources" : {
    "ResourceId" : "TopicA",
    "InstanceId" : "MQ_INST_188077086902****_BXSuW61e",
    "TagKey" : "CartService",
    "ResourceType" : "ALIYUN::MQ::TOPIC",
    "TagValue" : "ServiceA"
  }
}

Error codes

For a list of error codes, visit the API Error Center.

Operations in the Message Queue for Apache RocketMQ console

In addition to calling the ListTagResources operation, you can query the tags of resources in the Message Queue for Apache RocketMQ console. For more information, see Overview.