I have a Custom API set up in Azure Mobile Services (JS):
exports.post = function(request, response) {
var tables = request.service.tables;
var accounts = tables.getTable('Account');
var item = {
id: request.body.members.id
}
accounts.where(function (item) {
return this.id == item.id;
}, item).read({
success: function (results) {
if (results.length === 0) {
response.send(200, { Status: "FAIL", Error: "Something went wrong." });
}
else
{
var account = results[0];
response.send(200, {
id: account.id,
name: account.name,
email: account.email
});
}
}
});
};
I'm calling it from Android with:
List<Pair<String, String> > lp = new ArrayList<Pair<String, String> >();
lp.add(new Pair("id", userId));
mClient.invokeApi("custAPI", "POST", lp, whoami.class, new ApiOperationCallback<custAPI>() {
@Override
public void onCompleted(custAPI result,
Exception error, ServiceFilterResponse response) {
if (error == null) {
Log.w("TEST", result.name.toString());
}
}
});
The Custom API is being called but the parameters do not seem to be being passed - request.body.members.id
does not exist.
How do I properly pass parameters into a Custom API on Android?