Click here to Skip to main content
15,885,767 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
I have made a login api which will return an id when i pass username and password in android app.

public class LoginApiBody
{
    public string UserName { get; set; }
    public string Password { get; set; }
}

Say the link is http://abcd.org/efg/login. Currently the link is showing:

{  
   "message": "The request is invalid.", 
   "messageDetail": "The parameters dictionary contains a null entry for parameter 'Id' of non-nullable type 'System.Int32' for method System.Net.Http.HttpResponseMessage Get(Int32)' in 'KnwPortal.Controllers.UsersAPIController'. An optional parameter must be a reference type,  a nullable type, or be declared as an optional parameter." 
}

I have to pass 'UserName' and 'Password' to the server with POST method.My question is in which format i should send/pass my username and password? whether in JSONObject or something else? how he can verify whether the passed UserName and Password is there on the server or not?
or i am doing something wrong with my loginapi?

What I have tried:

I have tried this, but no success
Ion.with(User_Activity.this)
        .load("http://abcd.org/efg/login")
        .setBodyParameter("UsserName",user)
        .setBodyParameter("Password",pass)
        .asString()
        .setCallback(new FutureCallback() {
            @Override
            public void onCompleted(Exception e, Object result) {
                //on complete
            }
        });
Posted
Comments
wseng 18-Jun-18 4:38am    
Use POSTMAN to post first before you start writing your code.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900