Closed mowenwert closed 10 years ago
As it happens, DBpedia is returning a a JSON body, but the content-type is text/plain, which is parsed as N-Triples. In particular, the body returned is the following:
{ "head": { "link": [] }, "boolean": true}
The rest of the returned headers are:
{"date":["Tue, 29 Jul 2014 15:51:53 GMT"],"content-type":["text/plain"],"content-length":["43"],"connection":["keep-alive"],"server":["Virtuoso/07.10.3211 (Linux) i686-generic-linux-glibc212-64 VDB"],"accept-ranges":["bytes"]}
Note that the request is sent with Accept including various RDF formats, in addition to application/sparql-results+json and +xml; for some reason DBPedia isn't setting the content-type correctly.
commit 21ac68c8 on feature branch specific-accept attempts to address this by passing either RDF content types or SPARQL Results content types depending on the operation. Unfortunately, for SPARQL Update controls, it's not really clear what form expected results take. We use the following:
Those using RDF content types:
Those using SPARQL Results content types:
It would be great of watchers of this issue could validate this logic; it may not be a good idea at all, but I've seen similar issues on Dyrda, and now DBpedia.
cc/ @bendiken @moustaki
Would it be worth pushing that upstream? (The content-type definitely looks wrong on the DBpedia side)
I was looking for some more validation on the SPARQL Results content types, but if the consensus is to ship it, that's fine with me; we can always address later, if there are some endpoints that make different assumptions.
I'll put this on my queue.
Code:
gem 'sparql-client', '~> 1.1.2' require 'sparql/client'
sparql = SPARQL::Client.new("http://dbpedia.org/sparql")
result = sparql.ask.whether([:s, :p, :o]).true?
Error: /home/USER/.rvm/gems/ruby-2.1.2/gems/rdf-1.1.4.2/lib/rdf/reader.rb:410:in'
fail_subject': ERROR [line 1] Expected subject (found: "{ \"head\": { \"link\": [] }, \"boolean\": true}") (RDF::ReaderError) from /home/USER/.rvm/gems/ruby-2.1.2/gems/rdf-1.1.4.2/lib/rdf/ntriples/reader.rb:210:in
block in read_triple' from /home/USER/.rvm/gems/ruby-2.1.2/gems/rdf-1.1.4.2/lib/rdf/ntriples/reader.rb:204:inloop' from /home/USER/.rvm/gems/ruby-2.1.2/gems/rdf-1.1.4.2/lib/rdf/ntriples/reader.rb:204:in
read_triple' from /home/USER/.rvm/gems/ruby-2.1.2/gems/rdf-1.1.4.2/lib/rdf/reader.rb:391:inread_statement' from /home/USER/.rvm/gems/ruby-2.1.2/gems/rdf-1.1.4.2/lib/rdf/reader.rb:308:in
block in each_statement' from /home/USER/.rvm/gems/ruby-2.1.2/gems/rdf-1.1.4.2/lib/rdf/reader.rb:308:inloop' from /home/USER/.rvm/gems/ruby-2.1.2/gems/rdf-1.1.4.2/lib/rdf/reader.rb:308:in
each_statement' from /home/USER/.rvm/gems/ruby-2.1.2/gems/rdf-1.1.4.2/lib/rdf/util/aliasing.rb:46:inblock in alias_method' from /home/USER/.rvm/gems/ruby-2.1.2/gems/rdf-1.1.4.2/lib/rdf/mixin/countable.rb:12:in
empty?' from /home/USER/.rvm/gems/ruby-2.1.2/gems/sparql-client-1.1.2/lib/sparql/client/query.rb:268:intrue?' from /home/USER/tutorial_workspace/sentiment_dev/sparql_query.rb:6:in