2013-08-05 67 views
0

列出的網絡空間,我只是在爲一些工作,我標題進入準備與Azure的REST API的實驗過程中,當403 ...嘗試通過Azure的網站管理REST API

在節點。 JS我試圖獲取通過下面的代碼我的訂閱託管網站空間的列表...

var websiteOptions = { 
    hostname: 'management.core.windows.net', 
    path: '/<<Subscription-ID>>/services/webspaces', 
    method: 'GET', 
    pfx: new Buffer(managementCert, 'base64'), 
    strictSSL: true, 
    headers: { 
     'x-ms-version': '2013-06-01' 
    } 
}; 

websiteOptions.agent = new https.Agent(websiteOptions); 

var request = https.request(websiteOptions,function(res){ 
    console.log('Status Code:', res.statusCode); 
    console.log('Headers:', res.headers); 

執行時它返回..

<Error xmlns="http://schemas.microsoft.com/windowsazure" 
    xmlns:i="http://www.w3.org/2001/XMLSchema-instance"> 
    <Code>AuthenticationFailed</Code> 
    <Message>The server failed to authenticate the request. Verify that the certificate is valid and is associated with this subscription. 
    </Message> 
</Error> 

奇怪的是,如果我更換..

/<<subscription-ID>>/services/webspaces 

與...

/<<subscription-ID>>/services/hostedservices 

那個特定呼叫用得好好的,回來的託管服務列表 - 所以這使我相信,我的編碼/連接我的管理證書正確。

我已經嘗試過各種api版本,但沒有多少運氣,我也讀過這個article的各個部分,但沒有多少運氣。

那麼,爲什麼我的憑據在API的一個部分工作,而不是websties部分

我缺少什麼,我敢肯定,這是很簡單的東西:|

回答

1

行,所以現在我覺得愚蠢,這只是表明,即使是大公司可以得到它錯了..

我一直在玩多一點,並決定放棄斜線到的結束API網絡空間端點呼叫..和...

賓果...它的工作就像一個治療!

如果微軟在其API端點之間保持一致,本來是不錯的,例如託管服務端點不需要這個尾部斜線。

此外,準確的錯誤信息本來不錯,而不僅僅是報告無效憑證異常!

一如既往......生活中的簡單事物:(

相關問題