2

I'm querying a database in GraphDB using SPARQLWrapper. Insert is working fine but when the query is SELECT, I get HTTP 406 using GET method and HTTP 415 using POST. Similar Select query works on other databases like wikidata but not on GraphDB. Here is the query:

from SPARQLWrapper import SPARQLWrapper, JSON

sparql = SPARQLWrapper("http://localhost:7200/repositories/repo1/statements")

sparql.setQuery("""
PREFIX : <http://www.ontology.ca/ontology-1.0#>
    SELECT ?s WHERE { ?s a :User;
    :hasUserName "username1". }
""")
sparql.method = 'GET'
sparql.setReturnFormat(JSON)
results = sparql.query().convert()

PS: I tried other formats like xml, rdf, n3, etc. I don't get any error using RDF and N3 but the problem is the result is not filtered by the select query and contains all the triples existing in the ontology.

Can anyone please help me with this?

Eli
  • 21
  • 1
  • I don't get the problem. What happens if you use RDF and why would you use `RDF` at all for this query? It is a `SELECT` query which in fact does not return RDF, at least not triples from the ontology. It looks more like doing a request with RDF just returns a dump. What is the repository setup of your GraphDB? The code looks correct – UninformedUser Mar 30 '21 at 16:22
  • 5
    /repositories/repo1/statements isn't the SPARQL endpoint. The SPARQL endpoint is /repositories/repo1. More details: https://rdf4j.org/documentation/reference/rest-api/#repository-statements – AndyS Mar 30 '21 at 17:27
  • @UninformedUser I used RDF because was trying all the formats to see if I can have the result of the Select query. The problem was with the "statement" in the URI. – Eli Mar 31 '21 at 04:49

0 Answers0