Reputation: 1018
I have HTML/JS client trying to access APIController on Azure Mobile App service.
Following is my code
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)
});
The issue here is that my api's are published as such :
https://myapp.azurewebsites.net/Lookup/GetTransactionType?TenantID={{TenantID}}
But I get NOT FOUND error in client since its looking for following URL :
(XHR)GET - https://myapp.azurewebsites.net/api/Lookup/GetTransactionType?TenantID=1
How can I eliminate the /api in the URI?
Upvotes: 0
Views: 240
Reputation: 9950
As @rolspace mentioned, you need to call the .invokeApi
function with the absolute URL (must start with http://
or https://
) to eliminate the /api
in the URI.
So you can change the line of code to:
var pp = _client.invokeApi(_client.applicationUrl + "/Lookup/GetTransactionType", { //...
Upvotes: 1