2012-03-15 20 views
1

Wordnikから提供されたAPIを使用して認証トークンを取得しようとしています。しかし、私はそれを動作させるように見えることはできません。私は401と403のエラーを取得しているようだ。Wordnik認証エラー

次は私がAPIからの認証を要求するために使用していたコードです:

string authRequest = 
    String.Format("http://api.wordnik.com//v4/account.json/authenticate/{0}", 
    this.userName); 

HttpWebRequest request = WebRequest.Create(authRequest) as HttpWebRequest; 
request.Method = WebRequestMethods.Http.Post; 
request.ContentType = "application/x-www-form-urlencoded"; 

// When this is added, I get 403 errors 
///request.Headers.Add("api_key", APIKey); 

string postData = "password=" + password; 
byte[] encodedData = UTF8Encoding.UTF8.GetBytes(postData); 
request.ContentLength = encodedData.Length; 

Stream stream = request.GetRequestStream(); 
stream.Write(encodedData, 0, encodedData.Length); 
stream.Close(); 

string responseText; 

using(HttpWebResponse response = request.GetResponse() as HttpWebResponse) 
{ 
    using(StreamReader reader = new StreamReader(response.GetResponseStream())) 
    { 
     responseText = reader.ReadToEnd(); 
     Console.WriteLine(responseText); 
     Console.ReadLine(); 
    } 
} 

あなたのいずれかが、私が間違ってやっているものを私に伝えることができますか?

ご了承ください。

+1

何も間違っているようだ - あなたはhttps://groups.google.com/forum/?fromgroups#!forumに求めて試してみました/ wordnik-api? Googleグループです。 – JTeagle

+0

自分のグループに投稿を追加しました。ご協力ありがとうございました。 – achillesminor

答えて