Search code examples
androidkotlinretrofit2

how to android retrofit2 500 error clear?


As the postman communicates normally, there seems to be no problem on the server side.

postman enter image description here

and my Retrofit2 

open class RetrofitAPI {

    private val serverIp = "http://glowprdown-env.elasticbeanstalk.com/"

    companion object {
        private val ourInstance = RetrofitAPI()
        fun getInstance() = ourInstance
    }

    private val retrofit: Retrofit = Retrofit.Builder()
        .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
        .addConverterFactory(GsonConverterFactory.create())
        .baseUrl(serverIp)
        .build()

    val sampleApi: SampleAPI = retrofit.create(SampleAPI::class.java)
    val userApi: UserAPI = retrofit.create(UserAPI::class.java)
}

for interface ( controller )

interface UserAPI {

    @POST("user")
    fun login(
        @Query("userId") userId: String?,
        @Query("userName") userName: String?,
        @Query("password") password: String?,
        @Query("phone") phone: String?,
        @Query("gender") gender: String?,
        @Query("age") age: Int?,
        @Query("email") email: String?,
        @Query("provider") provider: String?,
        @Query("pushNotiFl") pushNotiFl: String?,
        @Query("kakaoNotiFl") kakaoNotiFl: String?,
        @Query("deviceToken") deviceToken: String?,
    ) : Single<UserResponse>

}

I googled it, but I thought it was an error that could come out because the address or endpoint was different. but it wasn't

Could you possibly point out what I did wrong? plz


Solution

  • From Pif and Daniel Nugent anwser.

    data class LoginRequest (
    @SerializedName("userId") val userId: String?,
    @SerializedName("userName")val userName: String?,
    @SerializedName("password") val password: String?,
    @SerializedName("phone") val phone: String?,
    @SerializedName("gender") val gender: String?,
    @SerializedName("age")val age: Int?,
    @SerializedName("email") val email: String?,
    @SerializedName("provider") val provider: String?,
    @SerializedName("pushNotiFl") val pushNotiFl: String?,
    @SerializedName("kakaoNotiFl")val kakaoNotiFl: String?,
    @SerializedName("deviceToken") val deviceToken: String?)
    
    
    interface UserAPI {
    @POST("user")
    fun login(
        @Body loginRequest :LoginRequest
    ) : Single<UserResponse>
    

    }