0
    String URL = "http://192.168.2.100:8080/DemoRest/webapi/aliens";

    RequestQueue requestQueue = Volley.newRequestQueue(this);

    JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(
            Request.Method.GET,
            URL,
            null,
            new Response.Listener<JSONObject>() {
                @Override
                public void onResponse(JSONObject response) {
                    Log.e("Rest Response: ",response.toString());
                }
            },
            new Response.ErrorListener() {
                @Override
                public void onErrorResponse(VolleyError error) {
                    Log.e("Rest Response: ",error.toString());
                }
            }
    );
    requestQueue.add(jsonObjectRequest);

Here i tried to get json data from my rest api.. where it is giving working properly on postman.. bu as i tried to link with android i am getting this error

Amol Khot
  • 17
  • 1
  • 2

2 Answers2

0

A similar issue was discussed here

If your server is running from your localhost and you are testing on an emulator you have to use the right IP address as specified in this documentation

Dracarys
  • 714
  • 7
  • 16
0
  1. Go to command prompt, write ipconfig
  2. Copy address of ipv4 and paste into your URL
  3. Go to manifest and give permission to internet
  4. In manifest inside application tag allow android:usesCleartextTraffic="true"
Ryan M
  • 18,333
  • 31
  • 67
  • 74