ruby-rdf / sparql-client

SPARQL client for Ruby.
http://rubygems.org/gems/sparql-client
The Unlicense
112 stars 58 forks source link

Infinite redirect error for unesco vocabulary sparql endpoint #88

Closed ConorSheehan1 closed 3 years ago

ConorSheehan1 commented 5 years ago

Unesco provide a sparql endpoint http://vocabularies.unesco.org/sparql-form/ The first example on that page is

SELECT ?s ?p ?o
WHERE {
  ?s ?p ?o .
} 
LIMIT 100

I tried to do the same thing using the sparql-client but I the following error:

sparql = SPARQL::Client.new("http://vocabularies.unesco.org/sparql")
query = sparql.select.where([:s, :p, :o]).limit(100)
query.each_solution {|solution| puts solution}

# error
SPARQL::Client::ServerError: Infinite redirect at http://vocabularies.unesco.org/sparql. Redirected more than 10 times.
  from /home/$user/.rbenv/versions/2.4.4/lib/ruby/gems/2.4.0/gems/sparql-client-1.99.1/lib/sparql/client.rb:699:in `request'
  from /home/$user/.rbenv/versions/2.4.4/lib/ruby/gems/2.4.0/gems/sparql-client-1.99.1/lib/sparql/client.rb:344:in `response'
  from /home/$user/.rbenv/versions/2.4.4/lib/ruby/gems/2.4.0/gems/sparql-client-1.99.1/lib/sparql/client.rb:305:in `query'
  from /home/$user/.rbenv/versions/2.4.4/lib/ruby/gems/2.4.0/gems/sparql-client-1.99.1/lib/sparql/client.rb:270:in `block in call_query_method'
  from /home/$user/.rbenv/versions/2.4.4/lib/ruby/gems/2.4.0/gems/sparql-client-1.99.1/lib/sparql/client/query.rb:416:in `result'
  from /home/$user/.rbenv/versions/2.4.4/lib/ruby/gems/2.4.0/gems/sparql-client-1.99.1/lib/sparql/client/query.rb:409:in `each_solution'
  from (irb):120
  from /home/$user/.rbenv/versions/2.4.4/lib/ruby/gems/2.4.0/gems/railties-4.2.10/lib/rails/commands/console.rb:110:in `start'
  from /home/$user/.rbenv/versions/2.4.4/lib/ruby/gems/2.4.0/gems/railties-4.2.10/lib/rails/commands/console.rb:9:in `start'
  from /home/$user/.rbenv/versions/2.4.4/lib/ruby/gems/2.4.0/gems/railties-4.2.10/lib/rails/commands/commands_tasks.rb:68:in `console'
  from /home/$user/.rbenv/versions/2.4.4/lib/ruby/gems/2.4.0/gems/railties-4.2.10/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
  from /home/$user/.rbenv/versions/2.4.4/lib/ruby/gems/2.4.0/gems/railties-4.2.10/lib/rails/commands.rb:17:in `<top (required)>'
  from bin/rails:4:in `require'
  from bin/rails:4:in `<main>'

http://vocabularies.unesco.org/sparql does redirect to http://vocabularies.unesco.org/sparql-form/,
but if the url has all the required params, e.g. this uri, generated by selecting the first query on the page and clicking run query, it resolves.

I'm not sure whether this is an issue with

  1. the unesco api
  2. the uri that gets build by the query not matching what unesco is expecting, or
  3. a case of altering config to increase the redirect threshold

I'm probably going to switch to using a regular http get for now using the url generated by the page,
but ideally I'd like to build the query using ruby. Thanks in advance!

gkellogg commented 3 years ago

The HTTP method is complaining about excessive redirects, so that would be coming from the server.