RetroFit 数据类的问题,返回空响应

问题描述

当我在浏览器中运行 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 响应代码。 请帮帮我。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)