Reputation: 1470
I am using Retrofit2 to make network requests but the endpoint is locally on my machine.
So my base URL is
private val BASE_URL = "http://localhost:8000/"
, but it gives me this response
Failed to connect to localhost/127.0.0.1:5000
So I did some search and I found out that I need to use my local IP address as the following
private val BASE_URL = "http:192.168.1.15//:8000/"
, but then I get this response
Response{protocol=http/1.1, code=404, message=Not Found, url=http://192.168.1.15//:8000/api/Home/RegisterShop}
Any idea how to solve this issue?
Upvotes: 1
Views: 11343
Reputation: 476
In my case the local server address was http://127.0.0.1:5000
(I used flask for my server, it runs on port 5000 by default)
Upvotes: 0
Reputation: 13
Things you should do:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"
and to <application>
:
<application
android:usesCleartextTraffic="true">
After that it should work... But keep in mind that if you go to prod, CleartextTraffic="true" is not a good idea.
Upvotes: 0