0

so as the post says, i'm making an app, for which i have a server/rest api written with the django framework. When i try to call the api using volley, i fail to get any response, and i don't see it show up on my server's dashboard

The server is running on my local machine, and the app is running on an emulator, since i'm using android studio

i'd like to send a request and display the response in a textview on the app, for now thats all i need to continue onto the next part

What ends up happening instead is that it seems to not even hit my server, the app displays the text i set for if the request fails, adn it doesn't show up on the dashboard of my server

here's basically all the code in my mobile app

 val textView = findViewById<TextView>(R.id.text)
        val queue = Volley.newRequestQueue(this)
        val url = "http://127.0.0.1:8000//index"//i also tried to use 192.168.1.2 as the host ip. the port is always 8000

        val stringRequest = StringRequest(Request.Method.GET, url,
            Response.Listener<String> { response ->
                // Display the first 500 characters of the response string.
                textView.text = "Response is: ${response.substring(0, 500)}"
            },
            Response.ErrorListener { textView.text = "That didn't work!" })

        queue.add(stringRequest)
double-beep
  • 5,031
  • 17
  • 33
  • 41
CodeR
  • 1
  • 1

1 Answers1

0

Please check the logs. They should show you a security error because you use HTTP clear text traffic.

With the default settings, apps aren't allowed to transmit cleartest HTTP traffic.

You must either add an SSL certificate to your backend or allow HTTP traffic. Check out this StackOverflow thread to see how to enable clear text web requests.

Alexander Hoffmann
  • 5,104
  • 3
  • 17
  • 23