RDFLib / sparqlwrapper

A wrapper for a remote SPARQL endpoint
https://sparqlwrapper.readthedocs.io/
Other
513 stars 121 forks source link

GraphDB 10.2.2: b'Missing parameter: query' on INSERT #233

Open frantony opened 3 months ago

frantony commented 3 months ago

I use SPARQLWrapper version 1.8.5-152-g2a6e2d3 with GraphDB 10.2.2 SPARQL endpoint.

Here is my my-example-insert.py script:

from SPARQLWrapper import SPARQLWrapper, POST

sparql = SPARQLWrapper("http://172.17.0.3:7200/repositories/test")

sparql.setMethod(POST)

sparql.setQuery("""
WITH <http://example.graph>
INSERT
{ <http://dbpedia.org/resource/Asturias> rdfs:label "Asturies"@ast }
""")

results = sparql.query()
print(results.response.read())

The script output:

$ python3 my-example-insert.py
Traceback (most recent call last):
  File "/workdir/test-sparql/SPARQLWrapper/Wrapper.py", line 926, in _query
    response = urlopener(request)
               ^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/urllib/request.py", line 216, in urlopen
    return opener.open(url, data, timeout)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/urllib/request.py", line 525, in open
    response = meth(req, response)
               ^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/urllib/request.py", line 634, in http_response
    response = self.parent.error(
               ^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/urllib/request.py", line 563, in error
    return self._call_chain(*args)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/urllib/request.py", line 496, in _call_chain
    result = func(*args)
             ^^^^^^^^^^^
  File "/usr/lib/python3.11/urllib/request.py", line 643, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 400: 

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/workdir/test-sparql/example-delete.py", line 13, in <module>
    results = sparql.query()
              ^^^^^^^^^^^^^^
  File "/workdir/test-sparql/SPARQLWrapper/Wrapper.py", line 960, in query
    return QueryResult(self._query())
                       ^^^^^^^^^^^^^
  File "/workdir/test-sparql/SPARQLWrapper/Wrapper.py", line 930, in _query
    raise QueryBadFormed(e.read())
SPARQLWrapper.SPARQLExceptions.QueryBadFormed: QueryBadFormed: A bad request has been sent to the endpoint: probably the SPARQL query is badly formed. 

Response:
b'Missing parameter: query'

I have the same problem with the DELETE request.

rajaram5 commented 2 months ago

I ran into same issue. Did you manage to find a solution? @frantony

frantony commented 1 month ago

@rajaram5

Did you manage to find a solution?

My solution is