Queries the tags of a resource.

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
RegionId String Yes cn-hangzhou

The ID of the region in which the resource is located.

ResourceType String Yes INSTANCE

The resource type. Set the value to INSTANCE.

Action String Yes ListTagResources

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

NextToken String No 6ab4640a-479b-41d0-ad3c-c6e888bc3d8f

Specify the token that is used to display the returned tags on multiple pages.

Tag.N.Key String No color

The key of the tag that you want to query.

Tag.N.Value String No red

The value of the tag that you want to query.

ResourceId.N String No dm-hbgau1zp****

The ID of the resource.

Response parameters

Parameter Type Example Description
NextToken String 6ab4640a-479b-41d0-ad3c-c6e888bc3d8f

The token that is used to display the returned tags on multiple pages.

RequestId String 58CE1CB0-F0F4-4BA3-B876-135DC47DF52F

The ID of the request.

Success Boolean true

Indicates whether the request is successful.

TagResources Array of TagResource

The list of returned tags.

TagResource
ResourceType String INSTANCE

The resource type. The value of this parameter is fixed to INSTANCE.

TagValue String 1

The value of the tag.

ResourceId String drdshzsd11****

The ID of the resource.

TagKey String test

The key of the tag.

Examples

Sample requests

http(s)://[Endpoint]/?RegionId=cn-hangzhou
&ResourceType=INSTANCE
&Action=ListTagResources
&NextToken=6ab4640a-479b-41d0-ad3c-c6e888bc3d8f
&Tag=[{"Key":"color","Value":"red"}]
&ResourceId=["dm-hbgau1zp****"]
&<Common request parameters>

Sample success responses

XML format

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

<ListTagResourcesResponse>
    <NextToken>6ab4640a-479b-41d0-ad3c-c6e888bc3d8f</NextToken>
    <RequestId>58CE1CB0-F0F4-4BA3-B876-135DC47DF52F</RequestId>
    <Success>true</Success>
    <TagResources>
        <ResourceType>INSTANCE</ResourceType>
        <TagValue>1</TagValue>
        <ResourceId>drdshzsd11****</ResourceId>
        <TagKey>test</TagKey>
    </TagResources>
</ListTagResourcesResponse>

JSON format

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

{
  "NextToken" : "6ab4640a-479b-41d0-ad3c-c6e888bc3d8f",
  "RequestId" : "58CE1CB0-F0F4-4BA3-B876-135DC47DF52F",
  "Success" : true,
  "TagResources" : [ {
    "ResourceType" : "INSTANCE",
    "TagValue" : "1",
    "ResourceId" : "drdshzsd11****",
    "TagKey" : "test"
  } ]
}

Error codes

HttpCode Error code Error message Description
500 InternalError The request processing has failed due to some unknown error. The error message returned because an internal error has occurred and the request failed.

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