我是 Django 的新手。我創建了一個名為 API 的 API http://127.0.0.1:8000/api/update/1/,它可以在瀏覽器和 Postman 應用程序中完美運行。但是,當我嘗試從 Android 應用程序訪問 API 時,它返回 NULL。當 API 如下時,android 代碼有效。http://newsapi.org/v1/articles?source=bbc-news&sortBy=top&apiKey=8190df9eb51445228e397e4185311a66但是,當 API 如下時它不起作用,即使以下 API 在我在同一臺 PC 上運行的瀏覽器和 Postman 應用程序中工作得很好。http://127.0.0.1:8000/api/update/1/我附上了進行 API 調用的代碼。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;}誰能幫我這個?提前致謝。
添加回答
舉報
0/150
提交
取消