Queries the tags that are added to the resources of various Alibaba Cloud services.
Usage notes
This topic provides an example on how to call the API operation to query the tags that are added to resources in the cn-hangzhou region. The response shows the following information:
- The tags
k1:v1
andk2:v2
are added to the Elastic Compute Service (ECS) instancei-bp15hr53jws84akg****
. - The tags
k1:v1
andk2:v2
are added to the diskd-bp16cat8zekjocv4****
. - The tags
k1:v1
andk2:v2
are added to the virtual private cloud (VPC)vpc-bp19dd90tkt6tz7wu****
.
Debugging
Request parameters
Parameter | Type | Required | Example | Description |
---|---|---|---|---|
Action | String | Yes | ListTagResources |
The operation that you want to perform. Set the value to ListTagResources. |
RegionId | String | Yes | cn-hangzhou |
The region ID of the resources. |
NextToken | String | No | caeba0bbb2be03f84eb48b699f0a**** |
The token that is used to start the next query. |
PageSize | Integer | No | 50 |
The number of entries to return on each page. Maximum value: 1000. Default value: 50. |
Tags | String | No | {"k1":"v1","k2":"v2"} |
The key-value pairs of tags. You can specify 1 to 10 key-value pairs. If you specify multiple tags, the system queries the resources to which all these tags are added. Limits:
|
Category | String | No | Custom |
The type of the tags. Valid values:
Default value: All. |
ResourceARN.N | String | No | arn:acs:ecs:cn-hangzhou:123456789****:instance/i-bp15hr53jws84akg**** |
The Alibaba Cloud Resource Names (ARNs) of the resources. For more information about supported resource types and ARN examples, see Types of resources that support Tag API operations. Valid values of N: 1 to 50. Example: ResourceARN.1 = arn:acs:${Service}:${Region}:${Account}:${ResourceType}/${ResourceId} |
For more information about common request parameters, see Common parameters.
Response parameters
Parameter | Type | Example | Description |
---|---|---|---|
NextToken | String | caeba0bbb2be03f84eb48b699f0a**** |
Indicates whether the next query is required.
|
RequestId | String | 014738E0-3C7F-47D8-8FB9-469500C6F387 |
The ID of the request. |
TagResources | Array of TagResource |
The information of the tags that are added to the resources. |
|
ResourceARN | String | arn:acs:ecs:cn-hangzhou:123456789****:instance/i-bp15hr53jws84akg**** |
The ARN of the resource. |
Tags | Array of Tag |
The information of the tags. |
|
Key | String | k1 |
The tag key. |
Value | String | v1 |
The tag value. |
Category | String | Custom |
The type of the tag. Valid values:
|
Examples
Sample requests
https://tag.aliyuncs.com/?Action=ListTagResources
&RegionId=cn-hangzhou
&<Common request parameters>
Sample success responses
XML
format
HTTP/1.1 200 OK
Content-Type:application/xml
<?xml version="1.0" encoding="UTF-8" ?>
<ListTagResourcesResponse>
<RequestId>014738E0-3C7F-47D8-8FB9-469500C6F387</RequestId>
<NextToken></NextToken>
<TagResources>
<ResourceARN>arn:acs:ecs:cn-hangzhou:123456789****:instance/i-bp15hr53jws84akg****</ResourceARN>
<Tags>
<Category>Custom</Category>
<Value>v2</Value>
<Key>k2</Key>
</Tags>
<Tags>
<Category>Custom</Category>
<Value>v1</Value>
<Key>k1</Key>
</Tags>
</TagResources>
<TagResources>
<ResourceARN>arn:acs:ecs:cn-hangzhou:123456789****:disk/d-bp16cat8zekjocv4z2fm</ResourceARN>
<Tags>
<Category>Custom</Category>
<Value>v1</Value>
<Key>k1</Key>
</Tags>
<Tags>
<Category>Custom</Category>
<Value>v2</Value>
<Key>k2</Key>
</Tags>
</TagResources>
<TagResources>
<ResourceARN>arn:acs:vpc:cn-hangzhou:123456789****:vpc/vpc-bp19dd90tkt6tz7wu****</ResourceARN>
<Tags>
<Category>Custom</Category>
<Value>v2</Value>
<Key>k2</Key>
</Tags>
<Tags>
<Category>Custom</Category>
<Value>v1</Value>
<Key>k1</Key>
</Tags>
</TagResources>
</ListTagResourcesResponse>
JSON
format
HTTP/1.1 200 OK
Content-Type:application/json
{
"RequestId" : "014738E0-3C7F-47D8-8FB9-469500C6F387",
"NextToken" : "",
"TagResources" : [ {
"ResourceARN" : "arn:acs:ecs:cn-hangzhou:123456789****:instance/i-bp15hr53jws84akg****",
"Tags" : [ {
"Category" : "Custom",
"Value" : "v2",
"Key" : "k2"
}, {
"Category" : "Custom",
"Value" : "v1",
"Key" : "k1"
} ]
}, {
"ResourceARN" : "arn:acs:ecs:cn-hangzhou:123456789****:disk/d-bp16cat8zekjocv4****",
"Tags" : [ {
"Category" : "Custom",
"Value" : "v1",
"Key" : "k1"
}, {
"Category" : "Custom",
"Value" : "v2",
"Key" : "k2"
} ]
}, {
"ResourceARN" : "arn:acs:vpc:cn-hangzhou:123456789****:vpc/vpc-bp19dd90tkt6tz7wu****",
"Tags" : [ {
"Category" : "Custom",
"Value" : "v2",
"Key" : "k2"
}, {
"Category" : "Custom",
"Value" : "v1",
"Key" : "k1"
} ]
} ]
}
Error codes
HTTP status code | Error code | Error message | Description |
---|---|---|---|
400 | InvalidParameter.Tags | The specified value of parameter Tags is not valid. | The error message returned because the value of the Tags parameter is invalid. |
403 | Duplicate.TagKey | The Tag.N.Key contains duplicate keys. | The error message returned because duplicate tag keys are specified. |
403 | Invalid.ResourceIdARN | The parameter ResourceIdARN is invalid. | The error message returned because the value of the ResourceARN parameter is invalid. |
403 | InvalidParameter.Category | The specified Category is invalid. Valid values are Custom and System. | The error message returned because the value of the Category parameter is invalid. The value can be Custom or System. |
403 | MissingParameter.ResourceIds | You must specify ResourceIds. | The error message returned because the ResourceIds parameter is not specified. |
403 | NoPermission.Operator | The user is not authorized to operate on the specified resource. | The error message returned because you are not authorized to perform the operation. |
403 | NoPermission.SystemTag | The user does not have permission to operate the system tag. | The error message returned because you are not authorized to perform operations on the system tag. |
403 | NoPermissionKey.Category | Some keys cannot be modified because the user does not have permission. | The error message returned because you are not authorized to perform operations on some tag keys. |
403 | NoPermissionKey.Operator | You are not authorized to operate the tag key. | The error message returned because you are not authorized to perform operations on the tag key. |
403 | NumberExceed.ResourceIds | The maximum number of ResourceIds is exceeded. | The error message returned because the maximum value of the ResourceIds parameter has been reached. |
403 | NumberExceed.Tags | The maximum number of Tags is exceeded. | The error message returned because the maximum value of the Tags parameter has been reached. |
403 | QuotaExceed.TagsPerResource | The maximum number of tags for each resource is exceeded. | The error message returned because the maximum number of tags for a resource has been reached. |
403 | Invalid.NextToken | The parameter NextToken is invalid. | The error message returned because the value of the NextToken parameter is invalid. |
403 | InvalidParameter.TagKey | The Tag.N.Key parameter is invalid. | The error message returned because the value of the TagKey parameter is invalid. |
403 | InvalidParameter.TagValue | The Tag.N.Value parameter is invalid. | The error message returned because the value of the TagValue parameter is invalid. |
403 | InvalidParameter.ResourceType | The ResourceType parameter is invalid. | The error message returned because the value of the ResourceType parameter is invalid. |
404 | Missing.TagKey | Tag.N.Value has been specified and you must specify Tag.N.Key. | The error message returned because the key of a tag is not specified. |
404 | MissingParameter.AliUid | You must specify AliUid. | The error message returned because the AliUid parameter is not specified. |
404 | MissingParameter.Bid | You must specify Bid. | The error message returned because the Bid parameter is not specified. |
404 | MissingParameter.RegionId | You must specify RegionId. | The error message returned because the RegionId parameter is not specified. |
404 | MissingParameter.RemoveNum | You must specify RemoveNum. | The error message returned because the RemoveNum parameter is not specified. |
404 | MissingParameter.ResourceIdARN | You must specify ResourceIdARN. | The error message returned because the ResourceIdARN parameter is not specified. |
404 | MissingParameter.TagKey | You must specify TagKey. | The error message returned because the TagKey parameter is not specified. |
404 | MissingParameter.Tags | You must specify Tags. | The error message returned because the Tags parameter is not specified. |
404 | NoMatch.RemoveNum | The specified DataNum does not match the deleted number. | The error message returned because the value of the RemoveNum parameter is invalid. |
For a list of error codes, visit the API Error Center.