Reputation: 35
I'm developing a tool based on Apache Jena 4.9.0 libraries to issue SELECT queries to a SPARQL endpoint, and execution resulted in error stated at the title (that is, "Endpoint returned Content-Type: application/sparql-results+json which is not recognized for SELECT queries.").
Does anyone know the reason and how to work around this?
My code is as follows and the triple stores at the endpoints are Virtuoso Open-Source Edition 7.2.13 and GraphDB 10.8.0:
HttpClient httpClient = HttpClient.newBuilder()
.connectTimeout(Duration.ofSeconds(shortTimeOut))
.followRedirects(Redirect.NORMAL)
.build();
QueryExecution gqexec = QueryExecutionHTTPBuilder
.service(ep)
.httpClient(httpClient)
.query(q)
.sendMode(QuerySendMode.asPost)
.timeout(longTimeOut, TimeUnit.SECONDS)
.build();
ResultSet rs = gqexec.execSelect();
And the query is
SELECT DISTINCT ?g WHERE { GRAPH ?g {?s ?p ?o} }
The followings are issued request from the tool:
Received POST request: POST /sparql HTTP/1.1
Headers:
Connection: Upgrade, HTTP2-Settings
Content-Length: 48
Host: localhost:8080
HTTP2-Settings: AAEAAEAAAAIAAAAAAAMAAAAAAAQBAAAAAAUAAEAAAAYABgAA
Upgrade: h2c
User-Agent: Java-http-client/21.0.5
Accept: application/sparql-results+json, application/sparql-results+xml;q=0.9, text/tab-separated-values;q=0.7, text/csv;q=0.5,application/json;q=0.2,application/xml;q=0.2,*/*;q=0.1
Content-Type: application/sparql-query;charset=utf-8
Body:
SELECT DISTINCT ?g WHERE { GRAPH ?g {?s ?p ?o} }
Best regards.
PS. The response data are as follows:
< HTTP/1.1 200 OK
< Server: Virtuoso/07.20.3240 (Linux) x86_64-ubuntu_focal-linux-gnu
< Connection: Keep-Alive
< Date: Wed, 27 Nov 2024 09:13:32 GMT
< Accept-Ranges: bytes
< Content-disposition: filename=sparql_2024-11-27_09-13-32Z.json
< Content-Type: application/sparql-results+json
< Content-Length: 12180
<
{ [12180 bytes data]
{ "head": { "link": [], "vars": ["g"] },
"results": { "distinct": false, "ordered": true, "bindings": [
{ "g": { "type": "uri", "value": "http://www.openlinksw.com/schemas/virtrdf#" }},
{ "g": { "type": "uri", "value": "http://www.w3.org/ns/ldp#" }},
...
Upvotes: 1
Views: 52