How can I call this api using retrofit only for login user
I can't access login method from my interface class in login activity.
Here is my api> http://localhost/AdminaService/AdminaService.svc/Verify_User_And_Password_For_login/{PUSER_ID}/{PPASSWORD}/{PUSER_SESSION_ID}/{PIPADDRESS}/{PAPPLICATION_ID}
Api interface
public interface Api {
@FormUrlEncoded
@POST("Verify_User_And_Password_For_login")
Call<LoginResponse>login(
@Path("PUSER_ID") String user_id,
@Path("PPASSWORD") String Ppassword
);
}
"Login activity"
public class LoginActivity extends AppCompatActivity {
private EditText edit_user, edit_pass;
private Button btn_login;
private static final String Base_url="http://localhost/AdminaService/AdminaService.svc/";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
getSupportActionBar().hide();
if (!isConnected(LoginActivity.this)) buildDialog(LoginActivity.this).show();
edit_user = findViewById(R.id.editText_username);
edit_pass = findViewById(R.id.editText_password);
btn_login=findViewById(R.id.button_signIn);
String U_id=edit_user.getText().toString().trim();
String pass=edit_pass.getText().toString().trim();
btn_login.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Retrofit retrofit = new Retrofit.Builder()
.baseUrl(Base_url)
.addConverterFactory(GsonConverterFactory.create())
.build();
Api api = retrofit.create(Api.class);
Call<LoginResponse> call = RetrofitClient
.getInstance()
.getApi()
.login(User_id,Ppassword);
call.enqueue(new Callback<LoginResponse>() {
@Override
public void onResponse(Call<LoginResponse> call,Response<LoginResponse> response) {
//After Login
}
@Override
public void onFailure(Call<LoginResponse> call,Throwable t) {
}
});
}
});
}
@Override
public void onStart() {
super.onStart();
}
@Override
public void onStop() {
super.onStop();
}
@Override
public void onResume() {
super.onResume();
}
@Override
public void onPause() {
super.onPause();
}
}
android retrofit2
add a comment |
I can't access login method from my interface class in login activity.
Here is my api> http://localhost/AdminaService/AdminaService.svc/Verify_User_And_Password_For_login/{PUSER_ID}/{PPASSWORD}/{PUSER_SESSION_ID}/{PIPADDRESS}/{PAPPLICATION_ID}
Api interface
public interface Api {
@FormUrlEncoded
@POST("Verify_User_And_Password_For_login")
Call<LoginResponse>login(
@Path("PUSER_ID") String user_id,
@Path("PPASSWORD") String Ppassword
);
}
"Login activity"
public class LoginActivity extends AppCompatActivity {
private EditText edit_user, edit_pass;
private Button btn_login;
private static final String Base_url="http://localhost/AdminaService/AdminaService.svc/";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
getSupportActionBar().hide();
if (!isConnected(LoginActivity.this)) buildDialog(LoginActivity.this).show();
edit_user = findViewById(R.id.editText_username);
edit_pass = findViewById(R.id.editText_password);
btn_login=findViewById(R.id.button_signIn);
String U_id=edit_user.getText().toString().trim();
String pass=edit_pass.getText().toString().trim();
btn_login.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Retrofit retrofit = new Retrofit.Builder()
.baseUrl(Base_url)
.addConverterFactory(GsonConverterFactory.create())
.build();
Api api = retrofit.create(Api.class);
Call<LoginResponse> call = RetrofitClient
.getInstance()
.getApi()
.login(User_id,Ppassword);
call.enqueue(new Callback<LoginResponse>() {
@Override
public void onResponse(Call<LoginResponse> call,Response<LoginResponse> response) {
//After Login
}
@Override
public void onFailure(Call<LoginResponse> call,Throwable t) {
}
});
}
});
}
@Override
public void onStart() {
super.onStart();
}
@Override
public void onStop() {
super.onStop();
}
@Override
public void onResume() {
super.onResume();
}
@Override
public void onPause() {
super.onPause();
}
}
android retrofit2
2
do you know whatlocalhost
means?
– Vladyslav Matviienko
Nov 26 '18 at 6:24
instead of localhost specify IP address of the machine where your server runs
– SaravInfern
Nov 26 '18 at 6:57
Please don't use plaintext passwords :(
– cricket_007
Nov 26 '18 at 7:14
I'm voting to close this question as a typo. Your variables areU_id
andpass
, notUser_id
andPpassword
– cricket_007
Nov 26 '18 at 7:17
give your full login url for testing.
– Android Team
Nov 26 '18 at 7:43
add a comment |
I can't access login method from my interface class in login activity.
Here is my api> http://localhost/AdminaService/AdminaService.svc/Verify_User_And_Password_For_login/{PUSER_ID}/{PPASSWORD}/{PUSER_SESSION_ID}/{PIPADDRESS}/{PAPPLICATION_ID}
Api interface
public interface Api {
@FormUrlEncoded
@POST("Verify_User_And_Password_For_login")
Call<LoginResponse>login(
@Path("PUSER_ID") String user_id,
@Path("PPASSWORD") String Ppassword
);
}
"Login activity"
public class LoginActivity extends AppCompatActivity {
private EditText edit_user, edit_pass;
private Button btn_login;
private static final String Base_url="http://localhost/AdminaService/AdminaService.svc/";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
getSupportActionBar().hide();
if (!isConnected(LoginActivity.this)) buildDialog(LoginActivity.this).show();
edit_user = findViewById(R.id.editText_username);
edit_pass = findViewById(R.id.editText_password);
btn_login=findViewById(R.id.button_signIn);
String U_id=edit_user.getText().toString().trim();
String pass=edit_pass.getText().toString().trim();
btn_login.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Retrofit retrofit = new Retrofit.Builder()
.baseUrl(Base_url)
.addConverterFactory(GsonConverterFactory.create())
.build();
Api api = retrofit.create(Api.class);
Call<LoginResponse> call = RetrofitClient
.getInstance()
.getApi()
.login(User_id,Ppassword);
call.enqueue(new Callback<LoginResponse>() {
@Override
public void onResponse(Call<LoginResponse> call,Response<LoginResponse> response) {
//After Login
}
@Override
public void onFailure(Call<LoginResponse> call,Throwable t) {
}
});
}
});
}
@Override
public void onStart() {
super.onStart();
}
@Override
public void onStop() {
super.onStop();
}
@Override
public void onResume() {
super.onResume();
}
@Override
public void onPause() {
super.onPause();
}
}
android retrofit2
I can't access login method from my interface class in login activity.
Here is my api> http://localhost/AdminaService/AdminaService.svc/Verify_User_And_Password_For_login/{PUSER_ID}/{PPASSWORD}/{PUSER_SESSION_ID}/{PIPADDRESS}/{PAPPLICATION_ID}
Api interface
public interface Api {
@FormUrlEncoded
@POST("Verify_User_And_Password_For_login")
Call<LoginResponse>login(
@Path("PUSER_ID") String user_id,
@Path("PPASSWORD") String Ppassword
);
}
"Login activity"
public class LoginActivity extends AppCompatActivity {
private EditText edit_user, edit_pass;
private Button btn_login;
private static final String Base_url="http://localhost/AdminaService/AdminaService.svc/";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
getSupportActionBar().hide();
if (!isConnected(LoginActivity.this)) buildDialog(LoginActivity.this).show();
edit_user = findViewById(R.id.editText_username);
edit_pass = findViewById(R.id.editText_password);
btn_login=findViewById(R.id.button_signIn);
String U_id=edit_user.getText().toString().trim();
String pass=edit_pass.getText().toString().trim();
btn_login.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Retrofit retrofit = new Retrofit.Builder()
.baseUrl(Base_url)
.addConverterFactory(GsonConverterFactory.create())
.build();
Api api = retrofit.create(Api.class);
Call<LoginResponse> call = RetrofitClient
.getInstance()
.getApi()
.login(User_id,Ppassword);
call.enqueue(new Callback<LoginResponse>() {
@Override
public void onResponse(Call<LoginResponse> call,Response<LoginResponse> response) {
//After Login
}
@Override
public void onFailure(Call<LoginResponse> call,Throwable t) {
}
});
}
});
}
@Override
public void onStart() {
super.onStart();
}
@Override
public void onStop() {
super.onStop();
}
@Override
public void onResume() {
super.onResume();
}
@Override
public void onPause() {
super.onPause();
}
}
android retrofit2
android retrofit2
edited Nov 26 '18 at 7:16
cricket_007
83.6k1146116
83.6k1146116
asked Nov 26 '18 at 6:10
Toufiqul Haque MamunToufiqul Haque Mamun
102
102
2
do you know whatlocalhost
means?
– Vladyslav Matviienko
Nov 26 '18 at 6:24
instead of localhost specify IP address of the machine where your server runs
– SaravInfern
Nov 26 '18 at 6:57
Please don't use plaintext passwords :(
– cricket_007
Nov 26 '18 at 7:14
I'm voting to close this question as a typo. Your variables areU_id
andpass
, notUser_id
andPpassword
– cricket_007
Nov 26 '18 at 7:17
give your full login url for testing.
– Android Team
Nov 26 '18 at 7:43
add a comment |
2
do you know whatlocalhost
means?
– Vladyslav Matviienko
Nov 26 '18 at 6:24
instead of localhost specify IP address of the machine where your server runs
– SaravInfern
Nov 26 '18 at 6:57
Please don't use plaintext passwords :(
– cricket_007
Nov 26 '18 at 7:14
I'm voting to close this question as a typo. Your variables areU_id
andpass
, notUser_id
andPpassword
– cricket_007
Nov 26 '18 at 7:17
give your full login url for testing.
– Android Team
Nov 26 '18 at 7:43
2
2
do you know what
localhost
means?– Vladyslav Matviienko
Nov 26 '18 at 6:24
do you know what
localhost
means?– Vladyslav Matviienko
Nov 26 '18 at 6:24
instead of localhost specify IP address of the machine where your server runs
– SaravInfern
Nov 26 '18 at 6:57
instead of localhost specify IP address of the machine where your server runs
– SaravInfern
Nov 26 '18 at 6:57
Please don't use plaintext passwords :(
– cricket_007
Nov 26 '18 at 7:14
Please don't use plaintext passwords :(
– cricket_007
Nov 26 '18 at 7:14
I'm voting to close this question as a typo. Your variables are
U_id
and pass
, not User_id
and Ppassword
– cricket_007
Nov 26 '18 at 7:17
I'm voting to close this question as a typo. Your variables are
U_id
and pass
, not User_id
and Ppassword
– cricket_007
Nov 26 '18 at 7:17
give your full login url for testing.
– Android Team
Nov 26 '18 at 7:43
give your full login url for testing.
– Android Team
Nov 26 '18 at 7:43
add a comment |
1 Answer
1
active
oldest
votes
@FormUrlEncoded
@POST("Verify_User_And_Password_For_login")
Call<LoginResponse>login(
@Path("PUSER_ID") String user_id,
@Path("PPASSWORD") String Ppassword
);
You may not pass login parameters as pathparams, Use @Field or @Query instead
@FormUrlEncoded
@POST("Verify_User_And_Password_For_login")
Call<LoginResponse>login(
@Field("PUSER_ID") String user_id,
@Field("PPASSWORD") String Ppassword
);
refer : https://square.github.io/retrofit/
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53475576%2fhow-can-i-call-this-api-using-retrofit-only-for-login-user%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
@FormUrlEncoded
@POST("Verify_User_And_Password_For_login")
Call<LoginResponse>login(
@Path("PUSER_ID") String user_id,
@Path("PPASSWORD") String Ppassword
);
You may not pass login parameters as pathparams, Use @Field or @Query instead
@FormUrlEncoded
@POST("Verify_User_And_Password_For_login")
Call<LoginResponse>login(
@Field("PUSER_ID") String user_id,
@Field("PPASSWORD") String Ppassword
);
refer : https://square.github.io/retrofit/
add a comment |
@FormUrlEncoded
@POST("Verify_User_And_Password_For_login")
Call<LoginResponse>login(
@Path("PUSER_ID") String user_id,
@Path("PPASSWORD") String Ppassword
);
You may not pass login parameters as pathparams, Use @Field or @Query instead
@FormUrlEncoded
@POST("Verify_User_And_Password_For_login")
Call<LoginResponse>login(
@Field("PUSER_ID") String user_id,
@Field("PPASSWORD") String Ppassword
);
refer : https://square.github.io/retrofit/
add a comment |
@FormUrlEncoded
@POST("Verify_User_And_Password_For_login")
Call<LoginResponse>login(
@Path("PUSER_ID") String user_id,
@Path("PPASSWORD") String Ppassword
);
You may not pass login parameters as pathparams, Use @Field or @Query instead
@FormUrlEncoded
@POST("Verify_User_And_Password_For_login")
Call<LoginResponse>login(
@Field("PUSER_ID") String user_id,
@Field("PPASSWORD") String Ppassword
);
refer : https://square.github.io/retrofit/
@FormUrlEncoded
@POST("Verify_User_And_Password_For_login")
Call<LoginResponse>login(
@Path("PUSER_ID") String user_id,
@Path("PPASSWORD") String Ppassword
);
You may not pass login parameters as pathparams, Use @Field or @Query instead
@FormUrlEncoded
@POST("Verify_User_And_Password_For_login")
Call<LoginResponse>login(
@Field("PUSER_ID") String user_id,
@Field("PPASSWORD") String Ppassword
);
refer : https://square.github.io/retrofit/
answered Nov 26 '18 at 7:02
SaravInfernSaravInfern
2,55411338
2,55411338
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53475576%2fhow-can-i-call-this-api-using-retrofit-only-for-login-user%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
2
do you know what
localhost
means?– Vladyslav Matviienko
Nov 26 '18 at 6:24
instead of localhost specify IP address of the machine where your server runs
– SaravInfern
Nov 26 '18 at 6:57
Please don't use plaintext passwords :(
– cricket_007
Nov 26 '18 at 7:14
I'm voting to close this question as a typo. Your variables are
U_id
andpass
, notUser_id
andPpassword
– cricket_007
Nov 26 '18 at 7:17
give your full login url for testing.
– Android Team
Nov 26 '18 at 7:43