2013-08-05 36 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端点之间保持一致,本来是不错的,例如托管服务端点不需要这个尾部斜线。

此外,准确的错误信息本来不错,而不仅仅是报告无效凭证异常!

一如既往......生活中的简单事物:(