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

QueryBadFormed: A bad request has been sent to the endpoint #224

Open
rjalexa opened this issue Jan 15, 2023 · 0 comments
Open

QueryBadFormed: A bad request has been sent to the endpoint #224

rjalexa opened this issue Jan 15, 2023 · 0 comments

Comments

@rjalexa
Copy link

rjalexa commented Jan 15, 2023

I am not understanding the source of this error. Here is a fully functional test code:

from SPARQLWrapper import SPARQLWrapper, JSON
endpoint = "http://dati.senato.it/sparql"
sparql = SPARQLWrapper(endpoint)
sparql.setReturnFormat(JSON)
# just a simple query only to debug
sparqlquery = "SELECT * WHERE {?s ?p ?o} LIMIT 1"
sparql.setQuery(sparqlquery)
ret = sparql.queryAndConvert()

which generates the following error message:

Exception has occurred: QueryBadFormed
QueryBadFormed: A bad request has been sent to the endpoint: probably the SPARQL query is badly formed. 

Response:
b"Virtuoso 37000 Error SP030: SPARQL compiler, line 0: Invalid character in SPARQL expression at '%'\n\nSPARQL query:\ndefine sql:big-data-const 0 \n#output-format:application/sparql-results+json\nSELECT %2A WHERE %7B%3Fs %3Fp %3Fo%7D LIMIT 1"
urllib.error.HTTPError: HTTP Error 400: Bad Request

During handling of the above exception, another exception occurred:

  File "/Users/bob/Documents/work/getnews/python test/misc/senato.py", line 18, in <module>
    ret = sparql.queryAndConvert()
          ^^^^^^^^^^^^^^^^^^^^^^^^
SPARQLWrapper.SPARQLExceptions.QueryBadFormed: QueryBadFormed: A bad request has been sent to the endpoint: probably the SPARQL query is badly formed. 

Response:
b"Virtuoso 37000 Error SP030: SPARQL compiler, line 0: Invalid character in SPARQL expression at '%'\n\nSPARQL query:\ndefine sql:big-data-const 0 \n#output-format:application/sparql-results+json\nSELECT %2A WHERE %7B%3Fs %3Fp %3Fo%7D LIMIT 1"

Environment:

MacOS Ventura
python                    3.11.0          h559f36b_0_cpython    conda-forge
sparqlwrapper             2.0.0              pyha770c72_0    conda-forge

remote Virtuoso endpoint: Virtuoso version 06.01.3127 on Linux (x86_64-unknown-linux-gnu), Single Server Edition
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

1 participant