0

I'm fetching data from API. I get the json response normally when I use the browser. But it's empty when I use retrofit. This this the api interface:

interface FootballApi {
@GET(".")
suspend fun getAllMatches(
 @Query("action") action:String = "get_events",
    @Query("match_live") match_live:String = "1",
    @Query("APIkey") apiKey:String = API_KEY

):Response<ApiResponse>

}

This is the path which I use it to get the json response from browser:

https://apiv3.apifootball.com/?action=get_events&match_live=1&APIkey=xxxxxx

When I log the response.body() this is what I get:

D/ViewModel: []

Any help?

Edit: I should note that it returns true when I check if (response.isSuccessful)

Roony
  • 23
  • 5
  • Why you have dot in `Get` as `@GET(".")`? Check the Okhttp Logs and see what URL is being called exactly . – ADM May 17 '22 at 08:12
  • @ADM Because as you can see the base url does not contain endpoints. So if you want to specify the base url without endpoints you should type "." to avoid errors. How can I see OkHttp logs? – Roony May 17 '22 at 08:23
  • 2
    https://stackoverflow.com/questions/32514410/logging-with-retrofit-2 – ADM May 17 '22 at 08:27
  • @ADM I got these messages: "200 Ok", "error 404, message: Authentication failed" – Roony May 17 '22 at 10:08
  • And the base url is lacking the queries – Roony May 17 '22 at 10:10

0 Answers0