【问题标题】:use cordova to call azure mobile app custom api使用cordova调用azure移动应用自定义api
【发布时间】:2017-07-25 05:43:49
【问题描述】:

我正在使用 cordova azure 移动应用程序插件连接到我的 azure 移动应用程序,我有一个自定义 api,我想从 cordova 客户端调用它,但带有参数。

我看到帖子How to call a custom function of Azure Mobile Service from Cordova mobile app?

这很有帮助,但它证明了没有参数的调用

我希望对如何配置我的客户端以调用我的自定义 api 并向其发送参数有所帮助

我的自定义 api 是这样的

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

我的 cordova 客户端应该是这样的:

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

那么我可以在哪里设置参数值?

【问题讨论】:

    标签: cordova azure azure-mobile-services


    【解决方案1】:

    您可以设置如下参数:

    var options = {
      method: 'GET',
      parameters: {
        param1: 'val1',
        param2: 'val2'
      }
    }
    
    client.invokeApi('Airports/GetByCode', options).then(createKeySuccess, createKeyFailure);
    

    有关详细 API 参考,请参阅 https://azure.github.io/azure-mobile-apps-js-client/MobileServiceClient.html#invokeApi

    【讨论】:

      猜你喜欢
      • 2016-11-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-04-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多