JENA: Endpoint returned Content-Type: text/html

。_饼干妹妹 提交于 2019-12-12 18:52:31

问题


When I try to send a sparql query to some endpoint, for example:

QueryExecution qe = QueryExecutionFactory.sparqlService("http://data.open.ac.uk/sparql",
                getStringForQuery());
        ResultSet results = qe.execSelect();

I get

Exception in thread "main" org.apache.jena.query.QueryException: Endpoint returned Content-Type: text/html which is not currently supported for SELECT queries
    at org.apache.jena.sparql.engine.http.QueryEngineHTTP.execResultSetInner(QueryEngineHTTP.java:372)
    at org.apache.jena.sparql.engine.http.QueryEngineHTTP.execSelect(QueryEngineHTTP.java:334)

And this is not the only one endpoint, to which I can't send query,

What should I do to get results in other content-type? I try to google it, but I found that it can happen if I send query to bad html (not sparql endpoint), but http://data.open.ac.uk/sparql is good endpoint, I send sparql query to it via python and everything was good.


回答1:


I don't know what kind of backend they use, but for whatever reason, you have to use an additional HTTP parameter force=true when using the SPARQL endpoint from external services:

http://data.open.ac.uk/sparql?force=true

Update:

According to Andy Seaborne from the Apache Jena development team, this is supposed to be a bug in the redirect in Jena 3.1.1. In version 3.1.0 the redirect to ?force=true works as expected. In addition, the backend is Fuseki 2.3.1.



来源:https://stackoverflow.com/questions/41926530/jena-endpoint-returned-content-type-text-html

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!