I'm trying to connect my android app with an API that runs on my PC.
I'm testing the app on my actual phone. The base URL is http://localhost:5000/api/.
object RequestManager {
val interceptor = HttpLoggingInterceptor()
val client = OkHttpClient.Builder().addInterceptor(interceptor).build()
init {
//TODO must be None at live
interceptor.level = HttpLoggingInterceptor.Level.BODY
}
val retrofit = Retrofit.Builder()
.baseUrl("http://localhost:5000/energy/api/")
.addConverterFactory(GsonConverterFactory.create())
.client(client)
.build()
val service = retrofit.create(Api::class.java)
}
I tried to go with http://< myIP >:5000/energy/api/ but I get a bad request message.
> D/OkHttp: <-- 400 Bad Request
Any help?