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
- An Alibaba Cloud account is created. To create an Alibaba Cloud account, visit the account registration page. Real-name verification is completed. ApsaraVideo VOD is activated.
- An AccessKey pair is created to call ApsaraVideo VOD operations. You can create the AccessKey pair of your Alibaba Cloud account in the User Management console. Alternatively, you can create a RAM user in the RAM console and grant the RAM user the permissions on ApsaraVideo VOD. For more information, see Create and grant permissions to a RAM user.
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.