Skip to content

Commit

Permalink
Fix in SPARQL post request to virtuoso (it's made differently when au…
Browse files Browse the repository at this point in the history
…thentication is enabled)
  • Loading branch information
Javier Sanchez committed Nov 30, 2023
1 parent 6b07c54 commit 9e69d46
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/linkeddata_api/data/sparql.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,19 @@ def post(
"""
headers = {
"accept": accept,
"content-type": "application/sparql-query",
"content-type": "application/x-www-form-urlencoded"
if "virtuoso.tern" in sparql_endpoint
else "application/sparql-query",
}

response = requests.post(
url=sparql_endpoint, headers=headers, data=query, timeout=60
)
if "virtuoso.tern" in sparql_endpoint:
response = requests.post(
url=sparql_endpoint, headers=headers, params={"query": query}, timeout=60
)
else:
response = requests.post(
url=sparql_endpoint, headers=headers, data=query, timeout=60
)

try:
response.raise_for_status()
Expand Down

0 comments on commit 9e69d46

Please sign in to comment.