This topic describes how to initialize ApsaraVideo VOD SDK for .NET by using an AccessKey pair and how to fix errors that occur during the calls of ApsaraVideo VOD operations.

Prerequisites

Initialize the SDK

Determine the region where you want to call ApsaraVideo VOD operations. For more information about the supported regions, see Access regions and IDs. For example, if you want to call the operations in the China (Shanghai) region, use cn-shanghai. In the following example, the AccessKey pair is used to initialize the SDK. Example:

using Aliyun.Acs.Core;
using Aliyun.Acs.Core.Profile;

public static DefaultAcsClient InitVodClient(string accessKeyId, string accessKeySecret)
{
    // The region where you want to call ApsaraVideo VOD operations.
    string regionId = "cn-shanghai";
    IClientProfile profile = DefaultProfile.GetProfile(regionId, accessKeyId, accessKeySecret);
    // DefaultProfile.AddEndpoint(regionId, regionId, "vod", "vod." + regionId + ".aliyuncs.com");
    return new DefaultAcsClient(profile);
}

Usage notes

Even if you call ApsaraVideo VOD operations from a region that is included in supported access regions and IDs, the system may return the error message SDK.InvalidRegionId, Can not find endpoint to access. due to SDK compatibility issues. For more information, see Access regions and IDs. To fix this error, invoke the AddEndpoint method that has been commented out in InitVodClient in the preceding example. The following figure shows an example.Usage notes