0

I have a 404 status error (page not found). I only want to send a request from my Android app to Mean.io web app through the following url:

http://192.168.0.103:3000/auth/register

I have also tried:

http://10.0.2.2:3000/auth/register

I had already googled but both of the solutions above didn't worked for me. However the url: http://192.168.0.103:3000/auth/register does work on my Chrome browser on my pc.

Here is the code:

public class AppConfig {

    // Server user register url
    //public static String URL_REGISTER = "http://10.0.2.2:3000/auth/register";
    public static String URL_REGISTER = "http://192.168.0.103:3000/auth/register";
}

If you want to know where the variable URL_REGISTER gets used. It's getting used in the registerUser() method.

I'm posting the method through a link, because the method is too big to post it here. In the link below you can see that the URL_REGISTER gets used on line 10.

Link: http://pastebin.com/ttH6upnb

superkytoz
  • 1,153
  • 2
  • 21
  • 41
  • Maybe the server is not accessible from device, try doing that with a public IP or try the app in emulator in your machine – Rajesh Batth Nov 21 '15 at 17:56
  • did you tried hitting that url from outside device like some HTTP client ? like Postman or browser ? – agpt Nov 21 '15 at 17:58
  • 1
    Did you try accessing this URL from your mobile chrome browser? from the same device you try to run your app from. – Udi Idan Nov 21 '15 at 17:59
  • 1
    404 means that you are reaching the server, and the server is returning the 404 error. Check your server logs to see what the problem is. – CommonsWare Nov 21 '15 at 18:00
  • @Udi Idan It also works from my mobile browser. – superkytoz Nov 21 '15 at 18:06
  • @CommonsWare it comes indeed from the server. Here is a screenshot of the logs link: http://i.imgur.com/yAwGdL3.png I'm still finding out how to fix it. – superkytoz Nov 21 '15 at 18:22

1 Answers1

0

1 be sure you connect to the server

192.168 and 10.0 are local addresses (not going to internet)

beware, if you get 404, perhaps another server like proxy responds to you

2 read this: Using java.net.URLConnection to fire and handle HTTP requests

3 begin by getting page "/" and check the headers (good server, etc.)

4 then verify your code, step by step

5 check if GET or POST, and authentication is not easy (check the headers)

Community
  • 1
  • 1