retrofit get request returns null

I use extract articles from news api and display them using paging 3 library in my project, but for some reason @GET request returns my response class but with null variable though on my profile on the news api site it shows that there was a request.

NewsApi class:

interface NewsApi {

companion object{
    const val CLIENT_ID = "356d64b4bfde4cd492ef415beabba030"
    const val BASE_URL = ""

@Headers("X-Api-Key: ${CLIENT_ID}")
suspend fun searchArticles (
    @Query("q") query: String,
    @Query("page") page: Int,
    @Query("pageSize") pageSize: Int,
) : NewsResponse


My Response class:

data class NewsResponse (
val results: List<NewsArticle>)


I tried your api and fetch the result, Your Api is fine, the problem is you try to get the result as

data class NewsResponse (
val results: List<NewsArticle>)

when the result is actually formed like this :

"author":"Igor Bonifacic",
"title":"University of ",
"description":"In aide built a robot to com…"

so change you result into :

data class NewsResponse(
    val status : String,
    val totalResults: Int,
    val articles: List<NewsArticle>

data class NewsArticle(
    val author: String,
    val description: String
Source: stackoverflow
The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 .