![](/img/trans.png)
[英]RackSpace CloudFiles how to use Asynchronous or Queue to send files using C#
[英]CloudFiles - Rackspace connection error c#
我正在嘗試使用其api連接到機架並傳遞我的用戶名和api密鑰,但出現此錯誤:
The remote server returned an error: (401) Unauthorized.
這是我的代碼:
UserCredentials userCreds = new UserCredentials("myusername", "myapikey");
Connection connection = new Connection(userCreds);
我遵循了本教程:
http://www.rackspace.com/knowledge_center/index.php/Sample_CSharp_Application
要求他們的支持,他們說我們可以使用curl來連接同一個鑰匙...他們不能提供太多幫助。
有誰有任何想法?
謝謝
對於在這里找到相同問題的其他人,我找到了解決方案,您基本上需要包括api uri:
http://blog.chmouel.com/2011/01/04/how-to-use-the-rackspace-cloud-uk-api/
您的示例有效,但我一直在尋找一種直接的方法,而無需使用包裝器。 這似乎也可以正常工作,並使用對Rackspace API的直接靜態訪問。
希望能幫助到你。 干杯。
string url = "https://auth.api.rackspacecloud.com/v1.0";
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.Headers.Add("X-Auth-User:" + userName);
request.Headers.Add("X-Auth-Key:" + apiKey);
request.Method = "GET";
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
{
string[] keys = response.Headers.AllKeys;
foreach (var k in keys)
Console.WriteLine(response.Headers[k]);
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.