我在宣布的移动服务的web api中有这个功能
Fish
这个函数在我的客户端声明
Animals
它适用于移动服务页面,但在我的客户端代码中返回null,抱歉,由于我的声誉,我无法附加图片...
答案 0 :(得分:2)
public async Task<bool> Login(string userName, string password)
{
LoginRequest loginRequest = new LoginRequest() { UserName = userName, Password = password };
try
{
var loginResult = await _service.InvokeApiAsync("EasyParkLogin", JToken.FromObject(loginRequest));
JObject json = JObject.Parse(loginResult.ToString());
_service.CurrentUser = new MobileServiceUser(json["user"]["userId"].ToString().Replace("EasyPark:", ""))
{
MobileServiceAuthenticationToken = json["authenticationToken"].ToString()
};
return true;
}
catch (Exception e)
{
return false;
}
}
通过更改代码:
HttpResponseMessage loginResult = await _service.InvokeApiAsync<LoginRequest, HttpResponseMessage>("EasyParkLogin", loginRequest);
JObject json = JObject.Parse(loginResult.Content.ToString());
要
var loginResult = await _service.InvokeApiAsync("EasyParkLogin", JToken.FromObject(loginRequest));
JObject json = JObject.Parse(loginResult.ToString());
答案 1 :(得分:-1)
尝试检查
的返回值DataTable