[英]Azure Mobile Service in xamarin forms existing code
I'm working on android app development. 我正在从事android应用程序开发。 I was using non-secure service end point, i am using below method for post the 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> ();
}
}
` But now i have changed the end points im using Secure end point. `但是现在我使用安全端点更改了端点即时消息。 I don't know how i can access the end point using MobileServiceClient(). 我不知道如何使用MobileServiceClient()访问端点。 Please help me if anybody have any idea. 如果有人有任何想法,请帮助我。
It looks like you are invoking a custom API, probably under /api/something - however, it's hard to tell as you have posted an incomplete example. 看起来您正在调用自定义API,可能在/ api / something下-但是,由于您发布了一个不完整的示例,因此很难分辨。 The code for this would look something like: 用于此的代码如下所示:
var client = new MobileServiceClient("https://foo.azurewebsites.net");
var result = await client.InvokeApiAsync<Model>("something", HttpMethod.Post);
Model is a class to receive the model you are expecting back. Model是用于接收您期望的模型的类。 It will handle the ZUMO-API-VERSION. 它将处理ZUMO-API-VERSION。 It will also handle authentication if you have it defined. 如果定义了身份验证,它还将处理身份验证。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.