2013-05-06 47 views
1

當我使用代碼波紋管對Parse.com未經授權的錯誤代碼訪問PARSE.COM

訪問類圖書
public void GetBook() 
    { 
     string RequestString = "https://api.parse.com/1/classes/Book"; 
     string ApplicationId = "my Application ID"; 
     string RestApiKey = "my REST API Key"; 

     WebRequest webRequest = WebRequest.Create(RequestString); 

     NetworkCredential streetCred = new NetworkCredential(ApplicationId, RestApiKey); 
     webRequest.Credentials = streetCred; 
     webRequest.Method = "GET"; 
     webRequest.Timeout = 100000; 
     HttpWebResponse b = (HttpWebResponse)webRequest.GetResponse(); 
    } 

這總是導致401未授權的響應。 我在做什麼錯?

+0

嗯,我不認爲'RestApiKey =「我的REST API密鑰」'是一個有效的密鑰。此外'ApplicationId'看起來可疑。除非你明白這些以便發佈你的問題?如果是這樣,請忽略此:) – Ryan 2013-05-06 01:57:15

+0

在實際代碼中存在實際值,從PARSE.COM站點複製粘貼。當我發佈我的佇列時,我將它們遮住了。 – 2013-05-06 02:04:07

+0

我唯一能說的是確保你的AppId和ApiKey是有效的。 401意味着你有無效的憑據。 – Ryan 2013-05-06 02:07:43

回答

0

我找到了我自己問題的答案!

看來所需的密鑰(NetworkCredentials中的第二個參數)應該是主密鑰而不是REST API密鑰。