All Products
Search
Document Center

Direct Mail:Tag operations

Last Updated:Sep 07, 2022

Create a tag

Delete a tag

Query tags

Create a tag

public void testCreatTag() {
        //If you are not in the China (Hangzhou) region, replace cn-hangzhou in the following code with your region ID. For example, if you are in the Singapore (Singapore) or Australia (Sydney) region, specify ap-southeast-1 or ap-southeast-2. 
        IAcsClient client = IAcsClientUtil.getiAcsClient();
        CreateTagRequest request = new CreateTagRequest();
        try {
            request.setTagName("testtag123567");
            CreateTagResponse httpResponse = client.getAcsResponse(request);
            System.out.println("------testCreatTag------" + JSON.toJSONString(httpResponse));
        } catch (ServerException e) {
            e.printStackTrace();
        } catch (ClientException e) {
            e.printStackTrace();
        }
    }

Delete a tag

public void testDeleteTag() {
        //If you are not in the China (Hangzhou) region, replace cn-hangzhou in the following code with your region ID. For example, if you are in the Singapore (Singapore) or Australia (Sydney) region, specify ap-southeast-1 or ap-southeast-2. 
        IAcsClient client = IAcsClientUtil.getiAcsClient();
        DeleteTagRequest request = new DeleteTagRequest();
        try {
            request.setTagId(24911);
            DeleteTagResponse httpResponse = client.getAcsResponse(request);
            System.out.println("------testDeleteTag------" + JSON.toJSONString(httpResponse));
        } catch (ServerException e) {
            e.printStackTrace();
        } catch (ClientException e) {
            e.printStackTrace();
        }
    }

Query tags

public void testQueryTagByParam() {
        IAcsClient client = IAcsClientUtil.getiAcsClient();
        QueryTagByParamRequest request = new QueryTagByParamRequest();
        try {
            request.setKeyWord("testtag1235");
            QueryTagByParamResponse httpResponse = client.getAcsResponse(request);
            System.out.println("------testQueryTagByParam------" + JSON.toJSONString(httpResponse));
        } catch (ServerException e) {
            e.printStackTrace();
        } catch (ClientException e) {
            e.printStackTrace();
        }
    }