当我在浏览器中运行API或不进行改造时,它会返回完美的响应。但当我通过改装和gson时,它返回null。我想我使用的数据类一定有问题。
我的API响应
{
"total_count": 1,
"incomplete_results": false,
"items": [
{
"login": "rishavnaskar",
"id": 59786899,
"node_id": "MDQ6VXNlcjU5Nzg2ODk5",
"avatar_url": "https://avatars.githubusercontent.com/u/59786899?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/rishavnaskar",
"html_url": "https://github.com/rishavnaskar",
"followers_url": "https://api.github.com/users/rishavnaskar/followers",
"following_url": "https://api.github.com/users/rishavnaskar/following{/other_user}",
"gists_url": "https://api.github.com/users/rishavnaskar/gists{/gist_id}",
"starred_url": "https://api.github.com/users/rishavnaskar/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/rishavnaskar/subscriptions",
"organizations_url": "https://api.github.com/users/rishavnaskar/orgs",
"repos_url": "https://api.github.com/users/rishavnaskar/repos",
"events_url": "https://api.github.com/users/rishavnaskar/events{/privacy}",
"received_events_url": "https://api.github.com/users/rishavnaskar/received_events",
"type": "User",
"site_admin": false,
"score": 1
}
]
}
请注意,";项目;是阵列
我的数据类
data class SearchPageUserModel(
@SerializedName("total_count") val total_count : Int,
@SerializedName("incomplete_results") val incomplete_results : Boolean,
@SerializedName("items") val items : List<Items>)
data class Items (
@SerializedName("login") val login : String,
@SerializedName("id") val id : String,
@SerializedName("node_id") val node_id : String,
@SerializedName("avatar_url") val avatar_url : String,
@SerializedName("gravatar_id") val gravatar_id : String,
@SerializedName("url") val url : String,
@SerializedName("html_url") val html_url : String,
@SerializedName("followers_url") val followers_url : String,
@SerializedName("following_url") val following_url : String,
@SerializedName("gists_url") val gists_url : String,
@SerializedName("starred_url") val starred_url : String,
@SerializedName("subscriptions_url") val subscriptions_url : String,
@SerializedName("organizations_url") val organizations_url : String,
@SerializedName("repos_url") val repos_url : String,
@SerializedName("events_url") val events_url : String,
@SerializedName("received_events_url") val received_events_url : String,
@SerializedName("type") val type : String,
@SerializedName("site_admin") val site_admin : Boolean,
@SerializedName("score") val score : Int)
它返回404响应代码。请帮帮我。
问题已经解决。显然,错误不在数据类中。
它在改装界面中。
我的界面错误
interface RetroFitService {
@GET("users")
fun searchUser(@Query("q") q: String): Call<SearchPageUserModel>}
我的界面没有错误(已解决(
interface RetroFitService {
@GET("search/users")
fun searchUser(@Query("q") q: String): Call<SearchPageUserModel>}