0

I create a rest api in Visual Studio . Than i'm trying to call this api from android. But i'm getting error when i use my URL (http://localhost:56662/api/Musteriler). I copied this tutorial : https://www.youtube.com/watch?v=EQse86iRKpg in my project. In this video using this URL: http://dev.superman-academy.com/api.php . I also tried to execute this URL and my program worked very good.

Is there someone help me about why my rest api URL doesn't work?

Getting these errors:

 01-06 07:49:20.148 28987-28987/? W/System: ClassLoader referenced unknown path: /data/app/com.guly.projecttabmenu-1/lib/x86
    01-06 07:14:48.600 31886-31886/com.guly.projecttabmenu W/InputEventReceiver: Attempted to finish an input event but the input event receiver has already been disposed.
    01-06 07:14:51.203 31886-31915/com.guly.projecttabmenu W/System.err:     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
    01-06 07:14:51.203 31886-31915/com.guly.projecttabmenu W/System.err:     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
    01-06 07:14:51.203 31886-31915/com.guly.projecttabmenu W/System.err:     at java.lang.Thread.run(Thread.java:818)

My restful api working on postman: enter image description here

1 Answers1

0

If it is a real Android device, then your server can't be accessed as localhost from other device.

You should locate your computer local IP address (you can find it by typing ipconfig or ifconfig in console). Once you find it, alter your request to use that address, something like http://192.168.1.2:56662/api/Musteriler.

You also need to make sure that your 56662 port is open, so other devices can access it.

JoKr
  • 4,976
  • 8
  • 27
  • 39
  • Thank you ! i did what you tell . But still not working. I added logcat errors to question. –  Jan 06 '17 at 12:25
  • I don't think that logcat gonna help us. Check: http://stackoverflow.com/a/36489319/4110778 and write real stacktrace. – JoKr Jan 06 '17 at 13:10
  • System.err: java.io.FileNotFoundException: http://192.168.2.1:56662/api/Musteriler taking this error:/ –  Jan 06 '17 at 14:25