【发布时间】:2017-05-23 17:23:03
【问题描述】:
我有 HTML/JS 客户端试图访问 Azure 移动应用服务上的 APIController。
以下是我的代码
var _client = new WindowsAzure.MobileServiceClient("https://myapp.azurewebsites.net/");
var pp = _client.invokeApi("/Lookup/GetTransactionType", {
body: null,
method: "get",
parameters: { TenantID: 1 },
headers: {
"ZUMO-API-VERSION": "2.0.0",
"Content-Type":"application/json",
"Cache-Control":"false",
"x-zumo-auth": "tada"
}
}).done(function (results) {
var message = results.results.count;
}, function (error) {
alert(error.message)
});
这里的问题是我的 api 是这样发布的:
https://myapp.azurewebsites.net/Lookup/GetTransactionType?TenantID={{TenantID}}
但我在客户端中收到 NOT FOUND 错误,因为它正在寻找以下 URL:
(XHR)GET - https://myapp.azurewebsites.net/api/Lookup/GetTransactionType?TenantID=1
如何消除 URI 中的 /api?
【问题讨论】:
-
似乎为了防止这种行为,您需要使用请求的绝对 url 调用 .invokeApi 函数:azure.github.io/azure-mobile-apps-js-client/…
标签: javascript azure-mobile-services