Queries the tags that are added to one or more resources.
Usage notes
Specify ResourceId.N or Tag.N (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 specify only Tag.N.Key, all tag values that are associated with the specified key are returned. If you specify only Tag.N.Value, an error message is returned.
If you specify 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
Request parameters
Parameter | Type | Required | Example | Description |
ResourceType | String | Yes | VPC | The resource type. Valid values:
Note The values are case-insensitive. |
NextToken | String | No | FFmyTO70tTpLG6I3FmYAXGKPd**** | The pagination token that is used in the next request to retrieve a new page of results. Valid values:
|
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. You can enter at most 50 IDs. Note Specify at least one of ResourceId.N and Tag.N (Tag.N.Key and Tag.N.Value). |
RegionId | String | Yes | cn-hangzhou | The ID of the region to which the resource belongs. You can call the DescribeRegions operation to query the most recent region list. |
Tag.N.Key | String | No | FinanceDept | The key of tag N to add to the resource. You can specify up to 20 tag keys. A tag key can be up to 128 characters in length and cannot be an empty string. It cannot start with Note Specify at least one of ResourceId.N and Tag.N (Tag.N.Key and Tag.N.Value). |
Tag.N.Value | String | No | FinanceJoshua | The value of tag N to add to the resource. You can specify up to 20 tag values. A tag value can be up to 128 characters in length and can be an empty string. It cannot start with Note Specify at least one of ResourceId.N and Tag.N (Tag.N.Key and Tag.N.Value). |
Action | String | Yes | ListTagResources | The operation that you want to perform. Set the value to ListTagResources. |
Response parameters
Parameter | Type | Example | Description |
NextToken | String | FFmyTO70tTpLG6I3FmYAXGKPd**** | A pagination token. It can be used in the next request to retrieve a new page of results. Valid values:
|
RequestId | String | DE65F6B7-7566-4802-9007-96F2494AC512 | The request ID. |
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 value of tag N. |
ResourceId | String | vpc-bp16qjewdsunr41m1**** | The resource ID. |
TagKey | String | FinanceDept | The key of tag N. |
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 |
400 | InvalidTagKey | The tag keys are not valid. | The tag index is invalid. |
400 | InvalidTagValue | The tag values are not valid. | The tag value is invalid. |
400 | InvalidInstanceType.NotFound | The instance type is not found | The instance type is not found. |
400 | InvalidInstanceIds.NotFound | The instanceIds are not found | The instance ID is not found. |
400 | Forbidden.TagKeys | The request do not allow to operate the tag keys | You do not have the permissions to specify TagKeys. |
400 | QuotaExceeded.TagNum | Custom Tags quota exceeded | The upper limit is reached. |
400 | Forbidden.NotAllowedCategary | The System tag is not valid | The system tag is invalid. |
400 | Forbidden.TagKeys | The request does not allow operate this tagkeys | You cannot manage the tag key by calling the operation. |
400 | Forbidden.TagKey.Duplicated | The specified tag key already exists. | The tag resources are duplicate. |
400 | SizeLimitExceeded.TagNum | The maximum number of tags is exceeded. | The number of tags has reached the upper limit. |
400 | SizeLimitExceeded.ResourceId | The maximum number of resource IDs is exceeded. | The number of resource group IDs has reached the upper limit. |
400 | BothEmpty.TagsAndResources | The specified Tags and ResourcesIds are not allow to both empty. | ResourceId.N and Tag.N are not specified. You must specify at least one of the parameters. |
400 | MissingParam.ResourceType | The param of ResourceType is missing. | ResourceType is not specified. |
403 | Forbidden | User not authorized to operate on the specified resource. | You are unauthorized to perform this operation on the specified resource. Acquire the required permissions and try again. |
For a list of error codes, see Service error codes.