Akamai api使用purge我的网址我很惊讶他授权标题没有正确的格式
获取错误响应httpresponse任何人告诉如何在c#中添加标题授权告诉如何解决问题,告诉我如何在我们的项目中调用akamai api .i有accessstoken和cilent token密钥也如何添加此令牌在此标题部分
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Net.Http;
using System.Web.Script.Serialization;
using System.Net.Http.Headers;
public partial class Purge : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
purge();
}
public async static void purge()
{
var baseAddress = new Uri(" https://akab-wbrwrbgi6t5urrvg-ohjpi4v6gxsib5aa.purge.akamaiapis.net/");
using (var httpClient = new HttpClient { BaseAddress = baseAddress })
{
httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("akab-jbl3s3ptctwvocrr-3fawkhddo47udqlg");
// httpClient.DefaultRequestHeaders.ExpectContinue = false;
using (var content = new StringContent("{ \"objects\": [ \"http://hindi.eenaduindia.com/News/National/2016/03/15150007/video-viral-of-a-girl-creating-ruckus-in-hyderabad.vpf\" ], \"action\": \"remove\", \"type\": \"arl\", \"domain\": \"production\"}", System.Text.Encoding.Default, "application/json"))
{
using (var response = await httpClient.PostAsync("ccu/v2/queues/default", content))
{
string responseData = await response.Content.ReadAsStringAsync();
var b = responseData.Replace('"', ' ');
var r = b.Split(',', '\n');
// Response.Write(r[1]);
}
}
}
}
}
答案 0 :(得分:1)
您需要使用Akamai签名库。这里有一个C#库: https://github.com/akamai-open/AkamaiOPEN-edgegrid-C-Sharp
图书馆的自述文件包含示例代码,以便开始将其集成到您的系统中。
谢谢, 姬