【发布时间】:2020-05-20 22:53:00
【问题描述】:
如何在 xamarin.forms 的 REST api 中发送参数?
我已经使用 PCL 在 xamarin 中创建了 REST API 项目。
当我在 Xamarin.forms(便携式类库)中使用以下代码调用 Simple REST api 时,我已成功接收 json 响应。
using (var cl = new HttpClient())
{
var result = await cl.GetStringAsync("http://192.168.1.100/apps/jara/web/api/user/test");
jsonResponseClass des = JsonConvert.DeserializeObject<jsonResponseClass>(result);
lbl1.Text = des.code + " " + des.status + " " + des.message;
}
public class jsonResponseClass
{
public string code { get; set; }
public string status { get; set; }
public string message { get; set; }
}
使用上面的代码我得到了响应
{
code: 200,
status: "ok",
message: "hello"
}
REST API 响应类型为 JSON,类型为 POST
现在,我想使用参数调用下面的登录 Api。
http://192.168.1.100/apps/jara/web/api/user/login
参数: email_id 和 密码
这个 api 成功响应类型是....
{
code: 200,
status: "Success",
User: {
userid: 126,
token: "d154s4d54s654df5s4df56s4df564s5df4",
email: "shahbuddin@gmail.com",
mobile_number: "9898989898"
},
message: "Successfully logged in"
}
我能做什么?
【问题讨论】:
标签: c# rest xamarin xamarin.forms