Skip to content

Commit

Permalink
Use POST instead of GET requests for SPARQL requests
Browse files Browse the repository at this point in the history
Some of the SPARQL endpoints we use now block GET requests that pass the SPARQL query as a URL query parameter. POST requests work fine for all endpoints.
  • Loading branch information
tillprochaska committed Jan 18, 2025
1 parent e1e0d46 commit 92e78bd
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions backend/howtheyvote/cli/dev.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,10 +357,9 @@ def _load_alt_labels(group_code: str) -> set[str]:


def exec_sparql_query(endpoint: str, query: str) -> Any:
params = {
"format": "application/sparql-results+json",
"query": query,
}

response = requests.get(endpoint, params=params)
response = requests.post(
endpoint,
data={"query": query},
headers={"Accept": "application/sparql-results+json"},
)
return response.json()["results"]["bindings"]

0 comments on commit 92e78bd

Please sign in to comment.