I am new to Django. I have created an API named http://127.0.0.1:8000/api/update/1/
and it works perfectly in the browser and on the Postman app.
However, when I am trying to access the API from the Android app it is returning NULL.
The Android code works when the API is the following:
http://newsapi.org/v1/articles?source=bbc-news&sortBy=top&apiKey=8190df9eb51445228e397e4185311a66
However, it does not work when the API is the following, even if the following API works just fine from my browser running in the same PC and from the Postman application.
http://127.0.0.1:8000/api/update/1/
I am attaching the code where API call is made.
protected String doInBackground(String... args) {
String xml = "";
String api = "http://127.0.0.1:8000/api/update/1/"; // returns NULL works in Postman app and in the browser
// String api = "http://newsapi.org/v1/articles?source=bbc-news&sortBy=top&apiKey=8190df9eb51445228e397e4185311a66"; // works in all places
String urlParameters = "";
xml = Function.excuteGet(api, urlParameters);
return xml;
}
and it works okay in the browser
. In the browser on that pc. Not in a browser on your device. – Goldsberry