Queries tags that are added to one or more instances.

  • 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
Action String Yes ListTagResources

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

RegionId String Yes cn-hangzhou

The ID of the region where the Classic Load Balancer (CLB) instance is created.

You can call the DescribeRegions operation to query the most recent region list.

ResourceType String Yes instance

The type of the resource. Valid values:

  • instance: a CLB instance
  • certificate: a certificate
  • acl: a network access control list (ACL)
NextToken String No caeba0bbb2be03f84eb48b699f0a****

The token that is used for the next query. Valid values:

  • If this is your first query or no next query is to be sent, ignore this parameter.
  • If a next query is to be sent, set the value to the value of NextToken that is returned in the last call.
Tag.N.Key String No FinanceDept

The key of the tag. Valid values of N: 1 to 20.

The tag key cannot be an empty string. It can be at most 64 characters in length, and cannot contain http:// or https://. It must not start with aliyun or acs:.

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.

It can be at most 128 characters in length, and cannot contain http:// or https://. It must not start with aliyun or acs:.

Response parameters

Parameter Type Example Description
NextToken String caeba0bbb2be03f84eb48b699f0a****

The token that is used for the next query. Valid values:

  • If NextToken is empty, it indicates that no next query is to be sent.
  • If NextToken is not empty, the value indicates the token that is used for the next query.
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
TagValue String FinanceJoshua

The value of tag N.

ResourceType String instance

The type of the resource.

ResourceId String lb-bp16qjewdsunr4******

The ID of the resource.

TagKey String FinanceDept

The key of tag N.

Examples

Sample requests

http(s)://[Endpoint]/?Action=ListTagResources
&ResourceOwnerId=111
&RegionId=cn-hangzhou
&ResourceType=instance
&NextToken=caeba0bbb2be03f84eb48b699f0a****
&ResourceId=["lb-bp1qnnvj18yy6h******"]
&Tag=[{"Key":"FinanceDept","Value":"FinanceJoshua"}]
&Common request parameters

Sample success responses

XML format

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

<ListTagResourcesResponse>
    <NextToken>caeba0bbb2be03f84eb48b699f0a****</NextToken>
    <RequestId>DE65F6B7-7566-4802-9007-96F2494AC512</RequestId>
    <TagResources>
        <TagValue>FinanceJoshua</TagValue>
        <ResourceType>instance</ResourceType>
        <ResourceId>lb-bp16qjewdsunr4******</ResourceId>
        <TagKey>FinanceDept</TagKey>
    </TagResources>
</ListTagResourcesResponse>

JSON format

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

{
  "NextToken" : "caeba0bbb2be03f84eb48b699f0a****",
  "RequestId" : "DE65F6B7-7566-4802-9007-96F2494AC512",
  "TagResources" : [ {
    "TagValue" : "FinanceJoshua",
    "ResourceType" : "instance",
    "ResourceId" : "lb-bp16qjewdsunr4******",
    "TagKey" : "FinanceDept"
  } ]
}

Error codes

HttpCode Error code Error message Description
400 TagTypeNotSame The category of tags in the same request must be the same. The error message returned because the specified tags in the request are of different types.
400 ResourceNotExist %s. The error message returned because the specified resource does not exist.
400 QueryTokenNotExist The specified NextToken does not exist. The error message returned because the specified token for the next query does not exist.
400 InvalidParam.NextToken The specified NextToken is invalid. The error message returned because the specified token for the next query is invalid. The error message returned because one or more specified parameters are invalid. Make sure that the parameters are valid and try again.
400 InvalidParam.Scope The specified Scope is invalid. The error message returned because the specified Scope is invalid. The error message returned because one or more specified parameters are invalid. Make sure that the parameters are valid and try again.
400 InvalidParam.ResourceType The specified ResourceType is invalid. The error message returned because the specified resource type is invalid. The error message returned because one or more specified parameters are invalid. Make sure that the parameters are valid and try again.
400 InvalidParam.TagKey The specified TagKey is invalid. The error message returned because the specified tag key is invalid. The error message returned because one or more specified parameters are invalid. Make sure that the parameters are valid and try again.
400 InvalidParam.TagValue The specified TagValue is invalid. The error message returned because the specified tag value is invalid. The error message returned because one or more specified parameters are invalid. Make sure that the parameters are valid and try again.
400 InvalidParam.TagKeyOrValue The specified TagKey or TagValue is invalid. The error message returned because the specified tag key or tag value is invalid. The error message returned because one or more specified parameters are invalid. Make sure that the parameters are valid and try again.
400 InvalidParam.TagOwnerUid The specified TagOwnerUid is invalid. The error message returned because the TagOwnerUid parameter is invalid. The error message returned because one or more specified parameters are invalid. Make sure that the parameters are valid and try again.
400 InvalidParam.TagOwnerBid The specified TagOwnerBid is invalid. The error message returned because the TagOwnerBid parameter is invalid. The error message returned because one or more specified parameters are invalid. Make sure that the parameters are valid and try again.
400 MissingParam.Scope The parameter Scope is required. The error message returned because the Scope parameter is not specified.
400 MissingParam.TagOwnerUid The parameter TagOwnerUid is required. The error message returned because the TagOwnerUid parameter is not specified.
400 MissingParam.TagOwnerBid The parameter TagOwnerBid is required. The error message returned because the TagOwnerBid parameter is not specified.
400 InvalidParameter.RegionId The specified RegionId does not exist. The error message returned because the specified region ID does not exist.
400 MissingParam.TagOrResourceId The parameter Tag or ResourceId is required at least one. The error message returned because the specified resource ID does not exist.
400 SizeLimitExceeded.ResourceId The maximum size of ResourceId is exceeded. The error message returned because the length of the specified resource ID exceeds the limit. The error message returned because one or more specified parameters are invalid. Make sure that the parameters are valid and try again.
400 SizeLimitExceeded.Tag The maximum size of Tag is exceeded. The error message returned because the length of the specified tag key exceeds the limit. The error message returned because one or more specified parameters are invalid. Make sure that the parameters are valid and try again.

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