我的回复在哪里以及我如何知道回复的状态

时间:2017-02-09 14:15:48

标签: c# .net asp.net-web-api http-post response

我写了一个代码来调用api ..但是无法理解对它的响应是什么:

    string secret = "=";
    string clientToken = "4xob3emhc";
    string accessToken = "akab-igw754pqdtlw6glf-2sjroprise6arn2h";
    string apiurl = "https://akab-7t4r7lq3a7d7-js5q6mdtx42qimcn.purge.akamaiapis.net/ccu/v3/invalidate/url/production";
    List<string> headers = new List<string>();
    string httpMethod = "POST";
    string outputfile = null;
    string data = "{\"hostname\": \"www.qa.wo.com\",\"objects\": [\"www.qa.wo.com/getmedia/9931b92a-c7f3-4a71-ab27-37e2b13572c0/should-be-here.jpg?width=2541&height=1811&ext=.jpg\"]}";
    int maxBodySize = 2048;

    EdgeGridV1Signer signer = new EdgeGridV1Signer(null, maxBodySize);
    ClientCredential credential = new ClientCredential(clientToken, accessToken, secret);

    Stream uploadStream = null;
    uploadStream = new MemoryStream(data.ToByteArray());

    var uri = new Uri(apiurl);
    var request = WebRequest.Create(uri);

    foreach (string header in headers) request.Headers.Add(header);
    request.Method = httpMethod;

    Stream output = Console.OpenStandardOutput();
    if (outputfile != null)
        output = new FileInfo(outputfile).OpenWrite();

    signer.Sign(request, credential, uploadStream);

    using (var result = signer.Execute(request, credential, uploadStream))
    {
        using (output)
        {
            using (result)
            {
                byte[] buffer = new byte[1024 * 1024];
                int bytesRead = 0;


                while ((bytesRead = result.Read(buffer, 0, buffer.Length)) != 0)
                {
                    output.Write(buffer, 0, bytesRead);
                }
            }
        }
    }

你能告诉我在哪里看到网络API呼叫的响应吗?

我在结果对象中找不到任何状态代码?应该在哪里呢?

我试图找出akamai清除是否发生。

我已从为控制台应用程序编写的代码中转换了此代码。看起来他们正在写入控制台,但我怎么能在运行时而不是控制台上看到响应。基本上我在寻找状态是“成功”

0 个答案:

没有答案