c# - Azure Mobile Service in xamarin forms existing code -
i'm working on android app development. using non-secure service end point, using below method post request:-
public static t get<t>(webrequest request, string requestdata=null) { string result=string.empty; request.contenttype = "application/json"; request.headers ["zumo-api-version"] = "2.0.0"; try { webresponse webresponse = task.factory.fromasync<webresponse> (request.begingetresponse, request.endgetresponse, null).result; using (var streamreader = new streamreader (webresponse.getresponsestream ())) { result = streamreader.readtoend (); } var typ = typeof(t); if ( typ == typeof(string) || typ == typeof(float) || typ == typeof(decimal) || typ == typeof(int16) || typ == typeof(int32) || typ == typeof(int64) ) { return (t) convert.changetype(result, typeof(t), null); } return result.fromjson<t> (); } catch(exception ex) { return result.fromjson<t> (); } }
` have changed end points im using secure end point. don't know how can access end point using mobileserviceclient(). please me if have idea.
it looks invoking custom api, under /api/something - however, it's hard tell have posted incomplete example. code like:
var client = new mobileserviceclient("https://foo.azurewebsites.net"); var result = await client.invokeapiasync<model>("something", httpmethod.post);
model class receive model expecting back. handle zumo-api-version. handle authentication if have defined.
Comments
Post a Comment