android retrofit2 500错误如何清除?
how to android retrofit2 500 error clear?
由于邮递员通信正常,服务器端似乎没有问题。
邮递员
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)
}
接口(控制器)
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>
}
我用谷歌搜索了一下,但我认为这是一个可能会出现的错误,因为地址或端点不同。但它不是
你能指出我做错了什么吗?请
来自Pif and Daniel Nugent 回复。
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>
}
由于邮递员通信正常,服务器端似乎没有问题。
邮递员
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)
}
接口(控制器)
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>
}
我用谷歌搜索了一下,但我认为这是一个可能会出现的错误,因为地址或端点不同。但它不是
你能指出我做错了什么吗?请
来自Pif and Daniel Nugent 回复。
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>
}