Let me tell you an easier way to do this. If you are using Android emulator you can use 10.0.2.2 as the IP address to connect to the host machine where your REST API is available.
Similarly if you are using Genymotion which uses Oracle Virtualbox, you can use 10.0.3.2.