16
我已經閱讀了一些其他帖子在堆棧,但我不能得到這個工作。curl與ASP.NET請求
private void BeeBoleRequest()
{
string url = "https://mycompany.beebole-apps.com/api";
WebRequest myReq = WebRequest.Create(url);
string username = "e26f3a722f46996d77dd78c5dbe82f15298a6385";
string password = "x";
string usernamePassword = username + ":" + password;
CredentialCache mycache = new CredentialCache();
mycache.Add(new Uri(url), "Basic", new NetworkCredential(username, password));
myReq.Credentials = mycache;
myReq.Headers.Add("Authorization", "Basic " + Convert.ToBase64String(new ASCIIEncoding().GetBytes(usernamePassword)));
WebResponse wr = myReq.GetResponse();
Stream receiveStream = wr.GetResponseStream();
StreamReader reader = new StreamReader(receiveStream, Encoding.UTF8);
string content = reader.ReadToEnd();
Response.Write(content);
}
這是BeeBole API:當我在我的混帳Windows機器上運行curl命令,但是當我將其轉換到ASP.NET它不工作,它工作正常在我的。它非常直接的前鋒。 http://beebole.com/api但是當我運行以上命令時出現以下500錯誤:
遠程服務器返回錯誤:(500)內部服務器錯誤。
謝謝。這很有用。 – Dkong