403.60调用Azure App Service Custom API POST时禁止访问

时间:2015-12-28 17:49:22

标签: azure azure-web-sites azure-mobile-services

我有一个名为'test.js'的Azure自定义API,如下所示:

exports.get = function (request, response) {
    response.send(statusCodes.OK, { message: 'Hello World!' });
};

exports.post= function (request, response) {
    response.send(statusCodes.OK, { message: 'Hello World!' });
};

我对应的test.json看起来像这样:

{
  "routes": {
    "*": {
      "get": {
        "permission": "user"
      },
      "post": {
        "permission": "user"
      },
      "put": {
        "permission": "user"
      },
      "patch": {
        "permission": "user"
      },
      "delete": {
        "permission": "user"
      }
    }
  }
}

我正在使用以下代码从apache cordova app调用post方法:

var azureClient = new WindowsAzure.MobileServiceClient("my-mobile-app", "mykey");
azureClient.invokeApi("test", {
                body: null
                method: "POST"
            })
            .done(function (results) {
                alert(results.response);
            }, function (error) {
                alert(error.message);
            });

我从服务器获得以下响应

<div class="content-container"> 
  <h3>HTTP Error 403.60 - Forbidden</h3> 
  <h4>You do not have permission to view this directory or page.</h4> 
</div> 
<div class="content-container"> 
 <fieldset><h4>Most likely causes:</h4> 
  <ul>  <li>This is a generic 403 error and means the authenticated user is not authorized to view the page.</li> </ul>

使用上面的代码调用GET方法工作正常,但POST返回错误。

非常感谢任何帮助。

更新

已经发出的HTTP请求如下所示:

http://mobl_m_mbl-[name-of-my-app-service]:80/api/test?[field]=[value]...

(其中field = value ...是POST参数的内容)

0 个答案:

没有答案