Skip to content

Commit

Permalink
Merge pull request #58 from ternaustralia/feature/allow_virtuoso_with…
Browse files Browse the repository at this point in the history
…_auth

Fix in SPARQL post request to virtuoso (it's made differently when au…
  • Loading branch information
javiersan18 authored Nov 30, 2023
2 parents 6b07c54 + 9e69d46 commit 40fcc3d
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 40fcc3d

Please sign in to comment.