I have Created azure Easy API.I can pass parameter values via Invoke API client method.But my problem is could not get schema name within API.am getting unexpected connection error.If enter manualy schema name i getting result.
IN my controller
$scope.saveuserdet = function (user) {
$scope.LicenceId = user.LicenceId;
$scope.username = user.username;
$scope.name = user.name;
var adduserclient = new WindowsAzure.MobileServiceClient('http//xxxxxxx');
adduserclient.invokeApi('APIname', {
body: null,
method: "post",
parameters: {
schemaname :'myschemaname',
license: $scope.LicenceId,
uname: $scope.username
}
}).done(function (results) {
var message = results.result.count + " item(s) marked as complete.";
}, function (error) {
$scope.showmessage = " Details are not Saved.Try Again";
});
};
module.exports = {
//"get": function (req, res, next) {
//}
"post": function (req, res, next) {
var query = {
// sql: 'EXEC **@schemaname.<Storedprocedurename>** @license,@uname ',
sql: 'EXEC **"'+ Myschema Name +'".<Storedprocedurename>** @license,@uname ',
parameters: [
{ name: 'schemaname', value: req.query.schemaname },
{ name: 'license', value: req.query.license },
{ name: 'uname', value: req.query.uname }]
};
req.azureMobile.data.execute(query).then(function (results) {
res.json(results);
});
}
};
I used your key code snippet to test on my side. It works fine. If you are using JavaScript Client Library for Azure Mobile Apps and test your application via a web server (test your application via visit Http://localhost:<port>
on a browser), it may caused by the CORS issue. You can set your local origin into the CORS section of your mobile app manage protal on Azure portal (https://ms.portal.azure.com).
Otherwise, you can press F12 of your browser, and set me if there is any error message when you running your application.
By the way, as you are using POST method, I suggest you to pass your data via body
parameter. E.G.,
client.invokeApi('APIname', {
method: "post",
body: {
schemaname :'myschemaname',
license: $scope.LicenceId,
uname: $scope.username
}
})
And in your Easy APIs script, you can get the data via res.body
.