Fatal Error :1:1: Content is not allowed in prolog

后端 未结 6 1017
旧时难觅i
旧时难觅i 2021-01-01 09:58

I\'m using Java and i\'m trying to get XML document from some http link. Code I\'m using is:

URL url = new URL(link);

HttpURLConnection connection = (HttpUR         


        
6条回答
  •  既然无缘
    2021-01-01 10:45

    Looks like you forgot adding correct headers to your get request (ask the REST API developer or you specific API description):

    HttpURLConnection connection = (HttpURLConnection)url.openConnection();
    connection.header("Accept", "application/xml")
    connection.setRequestMethod("GET");
    connection.connect();
    

    or

    connection.header("Accept", "application/xml;version=1")
    

提交回复
热议问题