[英]Android HttpsConnection - Internal Server Error
我想從我學校的網絡服務中獲取數據。 我在Eclipse中寫下代碼:
List<Predmet> getInfo(String osobniCislo) throws IOException
{
String target = "https://stag-ws.zcu.cz/ws/services/rest/rozvrhy/getRozvrhByStudent?osCislo="
+ "A12B0141P"
+ "&outputFormatEncoding=windows-1250";
URL url = new URL(target);
HttpsURLConnection https = (HttpsURLConnection)url.openConnection();
https.setConnectTimeout(5000); // 5s timeout
https.setRequestMethod("GET");
https.setInstanceFollowRedirects(true);
https.setUseCaches(false);
https.setDoOutput(true);
https.connect();
//Response cod
int responseCode = https.getResponseCode();
System.out.println(https.getResponseMessage());
}
這段代碼在Eclipse中運行良好,我得到了我想要的東西。 但當我將其復制到Android Studio時,我得到500 - Server Internal Error
。 我在清單中有特權:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
和其他網站工作正常。 有人知道哪里可能有問題嗎?
您獲得的錯誤是在服務器中生成的,因為它顯示500 - Server Internal Error
。 如果您的代碼在一個IDE中運行,那么如果您正確導入項目,它應該在另一個IDE中工作。 檢查導致錯誤的Web服務。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.