C# 如何从AmazonCloudFront.NETAPI获取失效请求列表?

C# 如何从AmazonCloudFront.NETAPI获取失效请求列表?,c#,.net,api,amazon-web-services,amazon-cloudfront,C#,.net,Api,Amazon Web Services,Amazon Cloudfront,我已经参考了API文档中的部分,但我不确定通过API发送的请求是否正确。这就是我的代码的样子: public class CfListInvalidation { string accessKeyID = ConfigurationManager.AppSettings["awsAccessID"]; string secretAccessKeyID = ConfigurationManager.AppSettings["awsSecretAnswer"]; string

我已经参考了API文档中的部分,但我不确定通过API发送的请求是否正确。这就是我的代码的样子:

public class CfListInvalidation
{
    string accessKeyID = ConfigurationManager.AppSettings["awsAccessID"];
    string secretAccessKeyID = ConfigurationManager.AppSettings["awsSecretAnswer"];
    string distributionId = ConfigurationManager.AppSettings["distributionId"];
    AmazonCloudFront client;

    public void SendCommand()
    {

        Console.WriteLine("Connecting to Amazon Cloud Front...");   

        using (client = AWSClientFactory.CreateAmazonCloudFrontClient(accessKeyID, secretAccessKeyID))
        {
            ListInvalidationsResult result = new ListInvalidationsResult();

            IAsyncResult r = client.BeginListInvalidations(new ListInvalidationsRequest
            {
                DistributionId = distributionId,                                        
            }, new AsyncCallback(CfListInvalidation.CompleteRead), result );                

        }
    }

    static void CompleteRead(IAsyncResult result)
    {
        ListInvalidationsResult r = result.AsyncState as ListInvalidationsResult;

        if (r != null && r.InvalidationList != null)
        {
            Console.WriteLine("listing items..");

            foreach (InvalidationSummary s in r.InvalidationList.Items)
            {
                Console.WriteLine(string.Format("ID: {0} - Status: {1}", s.Id, s.Status));
            }
        }

        else {
            Console.WriteLine("No Items Found");
        }
    }
}

我做错了什么吗?

使用Begin*方法时,需要调用匹配的End*方法来完成请求并检索结果对象。请看一些示例

以下是指南中的简化示例,说明了基本方法:

// Begin method
client.BeginPutObject(request, CallbackWithClient, client);

// Callback
public static void CallbackWithClient(IAsyncResult asyncResult)
{
  AmazonS3Client s3Client = (AmazonS3Client) asyncResult.AsyncState;
  PutObjectResponse response = s3Client.EndPutObject(asyncResult);

  // Process the response
}

使用Begin*方法时,需要调用匹配的End*方法来完成请求并检索结果对象。请看一些示例

以下是指南中的简化示例,说明了基本方法:

// Begin method
client.BeginPutObject(request, CallbackWithClient, client);

// Callback
public static void CallbackWithClient(IAsyncResult asyncResult)
{
  AmazonS3Client s3Client = (AmazonS3Client) asyncResult.AsyncState;
  PutObjectResponse response = s3Client.EndPutObject(asyncResult);

  // Process the response
}

您是否遇到任何问题,或者您只是想确保您的方法是正确的?您是否遇到任何问题,或者您只是想确保您的方法是正确的?