From bccc59ca74838865059873c7c5c7747c50dab5a5 Mon Sep 17 00:00:00 2001 From: Myst <1592048+LeMyst@users.noreply.github.com> Date: Sat, 6 Jun 2026 09:58:56 +0200 Subject: [PATCH] Send SPARQL query in POST body (fix execute_sparql_query) Change execute_sparql_query to send the SPARQL query in the POST body (data) instead of using params. Rename params->body, update debug log to reference body['query'], remove incorrect multipart Content-Type header, and switch helpers_session.post to use data=body. This ensures the query is transmitted as expected to SPARQL endpoints and avoids malformed multipart requests. # Conflicts: # wikibaseintegrator/wbi_helpers.py --- wikibaseintegrator/wbi_helpers.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/wikibaseintegrator/wbi_helpers.py b/wikibaseintegrator/wbi_helpers.py index 4729daac..1c7bcb75 100644 --- a/wikibaseintegrator/wbi_helpers.py +++ b/wikibaseintegrator/wbi_helpers.py @@ -274,7 +274,7 @@ def execute_sparql_query(query: str, prefix: str | None = None, endpoint: str | if prefix: query = prefix + '\n' + query - params = { + body = { 'query': '#Tool: WikibaseIntegrator wbi_functions.execute_sparql_query\n' + query, 'format': 'json' } @@ -287,11 +287,11 @@ def execute_sparql_query(query: str, prefix: str | None = None, endpoint: str | 'User-Agent': get_user_agent(user_agent) } - log.debug("SPARQL query:\n%s", params['query']) + log.debug("SPARQL query:\n%s", body['query']) for _ in range(max_retries): try: - response = helpers_session.post(sparql_endpoint_url, data=params, headers=headers, timeout=config['TIMEOUT']) + response = helpers_session.post(sparql_endpoint_url, data=body, headers=headers, timeout=config['TIMEOUT']) except requests.exceptions.ConnectionError as e: log.exception("Connection error: %s. Sleeping for %d seconds.", e, retry_after) sleep(retry_after)