mercredi 9 novembre 2016

Flurl Post Not Returning from Web Api

I've got a Xamarin application using Flurl, with the following post to a Web Api

Xamarin App:

    private async Task<LoginResponse> processLogin()
    {
        try
        {

            return await "http://192.168.0.12:60257/api/loginapi/Login".WithTimeout(10).PostJsonAsync(new { username = "fsdafsd", password = "gdfgdsf" }).ReceiveJson<LoginResponse>();
        }
        catch (Exception e)
        {
            return new LoginResponse { ResponseStatusCode = -1 };
        }
    }

Web Api:

public LoginResponse Login([FromBody]LoginRequest loginRequest)
{
    var result = new LoginResponse();

    try
    {
        var user = this.UserManager.FindAsync(loginRequest.username, loginRequest.password);

        if (user != null)
        {
            result.ResponseStatusCode = 1;
        }
        else
        {
            result.ResponseStatusCode = 0;
        }

    }
    catch (Exception e)
    {

        result.ResponseStatusCode = -1;
    }

    return result;

}

I can see my Web Api method getting hit, and it returns the expected object type, not my Xamarin application continues to wait on the Flurl Post.

Can anyone advise what I might be doing wrong?




Aucun commentaire:

Enregistrer un commentaire