application/sparql-results+json issue with graphdb endpoints
I'm having a issue when requesting to a graphdb endpoint, the reponse is always in srx format (application/sparql-results+xml) instead of srj format (application/sparql-results+xml).
I think the issue is caused because in the GET request LD-VOWL sends the parameter 'format=' instead of 'Accept='. This is what an appache2 server shows in access.log when it recieves the request from LD-VOWL:
27.0.0.1 - - [11/Mar/2021:11:11:11 +0100] "GET /repositories/phages?debug=on&format=application%2Fsparql-results%2Bjson&query=PREFIX+rdfs:+%3Chttp:%2F%2Fwww.w3.org%2F2000%2F01%2Frdf-schema%23%3E+PREFIX+skos:+%3Chttp:%2F%2Fwww.w3.org%2F2004%2F02%2Fskos%2Fcore%23%3E+SELECT+DISTINCT+%3Fclass+(count(%3Fsub)+AS+%3FinstanceCount)+WHERE+%7B+%3Fsub+a+%3Fclass.+%7D+GROUP+BY+%3Fclass+ORDER+BY+DESC(%3FinstanceCount)+LIMIT+10+OFFSET+0&timeout=30000 HTTP/1.1" 404 488 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:86.0) Gecko/20100101 Firefox/86.0"
In order to test it with graphdb I wrote that URL in a browser replacing format with Accept in following way, and graphddb served a JSON file as response:
In this way, graphdb serves a response in srj format as it should be. ¿Would be possible to add the possibility to work with graphdb endpoints?
Thanks so much.
Hi Raúl,
for content negotiation LD-VOWL should set the HTTP header Accept: application/sparql-results+json. The query parameter format is just another hint for endpoints ignoring the header.
Aside from that I can't reproduce the problem you describe on the LD-VOWL demo service: For me the SPARQL endpoint returns the results in JSON as expected (tested with Chromium 89 and Firefox 86). See http://vowl.visualdataweb.org/ldvowl/#/graph?endpointURL=https:%2F%2Fgraphdb.fortunalab.org%2Frepositories%2Fphages If you manually run the queries your browser will send different Accept headers and the endpoint will return XML.
Wild guess: Since your endpoint doesn't allow CORS it might be a problem with the proxy you use. Maybe this proxy doesn't forward the Accept header to the endpoint?
Ok, I see your point. It is working well with the on-line demo at http://vowl.visualdataweb.org
However, problem occurs when I run LD-VOWL in my local http server (ubuntu + appache2 and also ubuntu + nginx). I tested also some sparql endpoint (i.e. from dbpedia) and no one works, I always get message "Given ENDOPINT is not accessible". So, I suspect that it is a installation / configuration related issue.
On Google Chrome and Firefox debug console I see that it is trying to request to the online vowl site. This is the message at Chrome console:
Access to XMLHttpRequest at 'http://vowl.visualdataweb.org/ldvowl/proxy.php?debug=on&endpoint=https:%2F%2Fgraphd.fortunalab.org%2Frepositories%2Fphageon&format=application%2Fsparql-results%2Bjson&query=PREFIX+rdfs:+%3Chttp:%2F%2Fwww.w3.org%2F2000%2F01%2Frdf-schema%23%3E+PREFIX+skos:+%3Chttp:%2F%2Fwww.w3.org%2F2004%2F02%2Fskos%2Fcore%23%3E+SELECT+DISTINCT+%3Fclass+(count(%3Fsub)+AS+%3FinstanceCount)+WHERE+%7B+%3Fsub+a+%3Fclass.+%7D+GROUP+BY+%3Fclass+ORDER+BY+DESC(%3FinstanceCount)+LIMIT+10+OFFSET+0&timeout=30000' from origin 'http://localhost' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
What am I doing wrong?
Thaks so much.
Hi Raúl,
well your local instance tries to use the proxy of the demo service at http://vowl.visualdataweb.org which is different to http://localhost so you still have a CORS issue there.
If the endpoint you are trying to access does not allow CORS you have to use a proxy on the same origin, so if your webserver serves LD-VOWL at http://localhost, your proxy should be there too (e.g. http://localhost/proxy.php).
For configuring the proxy path when building LD-VOWL please have a look at #6
Have a nice weekend
Please ¿Could you share the link to the php script you are using as proxy?. Thanks so much.
Here is a gist of the php script I used as a proxy for testing purposes:
https://gist.github.com/marc92w/b71c2ae24e7d997a4ab96f0d0caf8943
I used a docker container with php and apache to serve this script together with a production build of LD-VOWL.