Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
frantony opened this issue Mar 24, 2024 · 2 comments
Open

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

frantony opened this issue Mar 24, 2024 · 2 comments

Comments

@frantony
Copy link

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
Copy link

rajaram5 commented May 3, 2024

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

@frantony
Copy link
Author

@rajaram5

Did you manage to find a solution?

My solution is

  • use ClioPatria server instead of GraphDB;
  • apply this patch to sparqlwrapper:
diff --git a/SPARQLWrapper/Wrapper.py b/SPARQLWrapper/Wrapper.py
index 977380a..b93c0e2 100644
--- a/SPARQLWrapper/Wrapper.py
+++ b/SPARQLWrapper/Wrapper.py
@@ -844,7 +844,7 @@ class SPARQLWrapper(object):
                 request = urllib.request.Request(uri)
                 request.add_header("Content-Type", "application/x-www-form-urlencoded")
                 request.data = self._getRequestEncodedParameters(
-                    ("update", self.queryString)
+                    ("query", self.queryString)
                 ).encode("ascii")
         else:
             # protocol details at http://www.w3.org/TR/sparql11-protocol/#query-operation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants