简体   繁体   English

Android HttpsConnection - 内部服务器错误

[英]Android HttpsConnection - Internal Server Error

I would like to get data from webservices of my school. 我想从我学校的网络服务中获取数据。 I write down code in Eclipse: 我在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());

    }

This code works fine in Eclipse and I get what I want. 这段代码在Eclipse中运行良好,我得到了我想要的东西。 But when I copied it into Android Studio, I'm getting 500 - Server Internal Error . 但当我将其复制到Android Studio时,我得到500 - Server Internal Error I have privilige in manifest: 我在清单中有特权:

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

and others websites works fine. 和其他网站工作正常。 Do someone have idea where could be a problem? 有人知道哪里可能有问题吗?

The error you are getting is generated in the server, as it shows 500 - Server Internal Error . 您获得的错误是在服务器中生成的,因为它显示500 - Server Internal Error If your code works in one IDE, it should work in another IDE if you have imported the project correctly. 如果您的代码在一个IDE中运行,那么如果您正确导入项目,它应该在另一个IDE中工作。 Check the web service you are using which is causing the error. 检查导致错误的Web服务。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM