Queries the tags that are added to one or more resources.
Usage notes
- Set ResourceId.N or Tag.N that consists of Tag.N.Key and Tag.N.Value in the request to specify the object to be queried.
- Tag.N is a resource tag that consists of a key-value pair. If you set only Tag.N.Key, all tag values that are associated with the specified key are returned. If you set only Tag.N.Value, an error message is returned.
- If you set Tag.N and ResourceId.N to filter tags, ResourceId.N must match all specified key-value pairs.
- If you specify multiple key-value pairs, resources that contain these key-value pairs are returned.
Debugging
OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.
Request parameters
Parameter | Type | Required | Example | Description |
---|---|---|---|---|
ResourceType | String | Yes | VPC |
The resource type. Valid values:
|
RegionId | String | Yes | cn-hangzhou |
The region ID of the resource. You can call the DescribeRegions operation to query the most recent region list. |
NextToken | String | No | FFmyTO70tTpLG6I3FmYAXGKPd**** |
The token that is used for the next query. Valid values:
|
Action | String | Yes | ListTagResources |
The operation that you want to perform. Set the value to ListTagResources. |
MaxResults | Integer | No | 50 |
The number of entries to return on each page. Valid values:1 to 50. Default value: 50. |
ResourceId.N | String | No | vpc-bp16qjewdsunr41m1**** |
The resource ID. Valid values of N: 1 to 20. |
Tag.N.Key | String | No | FinanceDept |
The key of the tag that is added to the resource. Valid values of N: 1 to 20. The tag key cannot be an empty string. The tag key cannot exceed 64 characters in
length, and can contain digits, periods (.), underscores (_), and hyphens (-). The
tag key must start with a letter but cannot start with |
Tag.N.Value | String | No | FinanceJoshua |
The value of the tag that is added to the resource. Valid values of N: 1 to 20. The tag value can be an empty string. The tag value cannot exceed 128 characters
in length, and can contain digits, periods (.), underscores (_), and hyphens (-).
The tag value must start with a letter but cannot start with |
Response parameters
Parameter | Type | Example | Description |
---|---|---|---|
NextToken | String | FFmyTO70tTpLG6I3FmYAXGKPd**** |
The token that is used for the next query. Valid values:
|
RequestId | String | DE65F6B7-7566-4802-9007-96F2494AC512 |
The ID of the request. |
TagResources | Array of TagResource |
The resources to which the tags are added. |
|
TagResource | |||
ResourceType | String | VPC |
The resource type. Valid values:
|
TagValue | String | FinanceJoshua |
The tag value. |
ResourceId | String | vpc-bp16qjewdsunr41m1**** |
The ID of the resource. |
TagKey | String | FinanceDept |
The tag key. |
Examples
Sample requests
http(s)://[Endpoint]/?ResourceType=VPC
&RegionId=cn-hangzhou
&NextToken=FFmyTO70tTpLG6I3FmYAXGKPd****
&Action=ListTagResources
&MaxResults=50
&ResourceId=["vpc-bp16qjewdsunr41m1****"]
&Tag=[{"Key":"FinanceDept","Value":"FinanceJoshua"}]
&<Common request parameters>
Sample success responses
XML
format
HTTP/1.1 200 OK
Content-Type:application/xml
<ListTagResourcesResponse>
<NextToken>FFmyTO70tTpLG6I3FmYAXGKPd****</NextToken>
<RequestId>DE65F6B7-7566-4802-9007-96F2494AC512</RequestId>
<TagResources>
<ResourceType>VPC</ResourceType>
<TagValue>FinanceJoshua</TagValue>
<ResourceId>vpc-bp16qjewdsunr41m1****</ResourceId>
<TagKey>FinanceDept</TagKey>
</TagResources>
</ListTagResourcesResponse>
JSON
format
HTTP/1.1 200 OK
Content-Type:application/json
{
"NextToken" : "FFmyTO70tTpLG6I3FmYAXGKPd****",
"RequestId" : "DE65F6B7-7566-4802-9007-96F2494AC512",
"TagResources" : [ {
"ResourceType" : "VPC",
"TagValue" : "FinanceJoshua",
"ResourceId" : "vpc-bp16qjewdsunr41m1****",
"TagKey" : "FinanceDept"
} ]
}
Error codes
HttpCode | Error code | Error message | Description |
---|---|---|---|
403 | Forbidden | User not authorized to operate on the specified resource. | The error message returned because you are unauthorized to perform the operation on the specified resource. Acquire the required permissions and try again. |
For a list of error codes, visit the API Error Center.