RetroFit Dataclass 的问题,返回空响应

Problem with RetroFit Dataclass, returning null response

当我 运行 在浏览器中 API 或不进行改造时,它 returns 一个完美的响应。但是当我通过改造和 gson 传递它时,它 returns 为空。我认为我正在使用的数据 classes 一定有问题。

我的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
}
]
}

请注意“项目”是一个数组

我的数据class

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)

IT RETURNS 404 响应代码。 请帮帮我。

解决了。显然错误不在数据 class.

在改装界面

我的界面有错误

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>}