13

I build a restAdapter by this:

    return new RestAdapter.Builder()
            .setEndpoint("https://www.xyz.com/")
            .build()
            .create(SafeUserApi.class);

then in the SafeUserApi.class (which is an interface) I have:

public interface SafeUserApi {
    @POST("/api/userlogin")
    void getUserLogin(@Body UserserLogin userLogin, Callback<LoginResult> cb);
}

But it does not work. Did I miss something?

I tried with Postman and it works. But in my device it doesn't.

I have these four library imported:

compile files('libs/okhttp-2.1.0.jar')
compile files('libs/okhttp-urlconnection-2.1.0.jar')
compile files('libs/okio-1.0.1.jar')
compile files('libs/retrofit-1.8.0.jar')
Derekyy
  • 1,018
  • 4
  • 18
  • 31
  • How it doesnt work? Give the symptomps. – Nikola Despotoski Dec 31 '14 at 08:12
  • I solved it. I didnt include the keystore in my project. It takes me quite a while to gen the keystore. I used keystoreExplorer to gen the keystore, it is very easy wif that tool – Derekyy Jan 04 '15 at 12:07
  • I have the same problem and my retrofit request failure with error: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found. – Mahdi Dec 13 '17 at 09:31

1 Answers1

-7
public interface SafeUserApi {
    @FormUrlEncoded
    @POST("/api/userlogin")
    void getUserLogin(@Field("parm1")UserserLogin userLogin, Callback<LoginResult> cb);
}

Here parm1 is the POST parameter that you will be passing it to the server. This will solve your problem

Gowtham Raj
  • 2,915
  • 1
  • 24
  • 38