0
votes

I'm using cordova azure mobile app plugin to connect to my azure mobile app, where I have a custom api and I want to call it from cordova client but with parameters.

I saw the post How to call a custom function of Azure Mobile Service from Cordova mobile app?

and it was helpful but it demonistrate the calling without parameters

I hope to have a help on how to configure my client to call my custom api and send parameters to it

my custom api is like

[MobileAppController]
    public class AirportsController : ApiController
    {
        public string GetByCode(int Code)
        {
            return Code.ToString();
        }
    }

where my cordova client should look like:

client = new WindowsAzure.MobileServiceClient('https://MYAZURESITE.azurewebsites.net');
client.invokeApi('Airports/GetByCode', { method: 'GET' }).then(createKeySuccess, createKeyFailure);

So where I could set my parameters value?

1

1 Answers

2
votes

You could set parameters like below:

var options = {
  method: 'GET',
  parameters: {
    param1: 'val1',
    param2: 'val2'
  }
}

client.invokeApi('Airports/GetByCode', options).then(createKeySuccess, createKeyFailure);

Refer to https://azure.github.io/azure-mobile-apps-js-client/MobileServiceClient.html#invokeApi for detailed API reference.