c# - Azure Mobile Services Sync Context: Adding custom parameters -


i using azure mobile services provide data windows universal app , azure api management proxy api usage , analytics purposes. working great.

now asked provide offline functionality application started using azure mobile services synchronization context in order implement using sqlite local store.

azure api management requires me send subscription key part of query string. have been doing using 'parameters' dictionary provided imobileservicetable.insertasync method , working fine well.

now offline implementation requires me use imobileservicesynctable.insertasync method instead, doesn't provide overload 'parameters' dictionary. mobileservicesynccontextextensions.pushasync method not seem provide way add custom parameters query string either.

does know of way include custom parameters when using mobile services synchronization context in order send subscription key of azure api management service?

i've found way this.

i implemented following http message handler:

using system; using system.collections.generic; using system.net.http; using system.text;  class azureapimanagementhandler : delegatinghandler {      string _subscriptionkey;      public azureapimanagementhandler(string subscriptionkey)     {         _subscriptionkey = subscriptionkey;     }      protected override system.threading.tasks.task<httpresponsemessage> sendasync(httprequestmessage request, system.threading.cancellationtoken cancellationtoken)     {         var baseuri = new uribuilder(request.requesturi);         string querytoappend = string.format("subscription-key={0}", _subscriptionkey);          if (baseuri.query != null && baseuri.query.length > 1)             baseuri.query = baseuri.query.substring(1) + "&" + querytoappend;         else             baseuri.query = querytoappend;          request.requesturi = baseuri.uri;         return base.sendasync(request, cancellationtoken);     } } 

and passed mobile services client in constructor:

    public static mobileserviceclient mobileservice = new mobileserviceclient(          "https://yoursubdomainhere.azure-api.net",          "yourapikeyhere",          new azureapimanagementhandler("yoursubscriptionkeyhere")     ); 

i hope useful facing same problem.


Comments

Popular posts from this blog

c++ - OpenMP unpredictable overhead -

ruby on rails - RuntimeError: Circular dependency detected while autoloading constant - ActiveAdmin.register Role -

javascript - Wordpress slider, not displayed 100% width -