This topic describes how to use Alibaba Cloud SDK for Java to call the SearchTemplate operation to search for custom transcoding templates.


Before you begin, ensure that the following requirements are met:
  • You must have an Alibaba Cloud account and an AccessKey pair (AccessKey ID and AccessKey secret) to use Alibaba Cloud SDK for Java. You can create and view your AccessKey pair on the AccessKey Management page in the Alibaba Cloud Management Console.
  • You have installed Alibaba Cloud SDK for Java. For more information about SDK versions, see Alibaba Cloud SDK.
            <! -- -->
        <! -- -->

Sample code

This section shows the sample code:
import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.IAcsClient;
import com.aliyuncs.exceptions.ClientException;
import com.aliyuncs.exceptions.ServerException;
import com.aliyuncs.mts.model.v20140618.*;
import com.aliyuncs.profile.DefaultProfile;

public class TestSearchTemplate {

    public static void main(String[] args) {        
        // Initialize request parameters.
        DefaultProfile profile = DefaultProfile.getProfile(
                "<your-region-id>",         // The ID of the region.
                "<your-access-key-id>",     // The AccessKey ID.
                "<your-access-key-secret>"); // The AccessKey secret.
        IAcsClient client = new DefaultAcsClient(profile);
        SearchTemplateRequest request = new SearchTemplateRequest();
        // The status of the transcoding template. Valid values: All, Normal, and Deleted. Default value: All.
        // Paging. Default values: PageNumber = 1L. PageSize = 10L.
        try {
            SearchTemplateResponse response = client.getAcsResponse(request);
            System.out.println(new Gson().toJson(response));
        } catch (ServerException e) {
        } catch (ClientException e) {
            System.out.println("ErrCode:" + e.getErrCode());
            System.out.println("ErrMsg:" + e.getErrMsg());
            System.out.println("RequestId:" + e.getRequestId());