Reputation: 43
I am trying to delete/clear data from a named graph using python. Used approach
import requests
url = "neptune_endpoint:8182/sparql"
query = "CLEAR GRAPH IRIref."
PARAMS = {"query" :query}
r = requests.get(url, params= PARAMS)
getting error malformed query. Thanxs in advance for help.
Upvotes: 0
Views: 637
Reputation: 211
The following code should work for you.
import requests
url = "neptune_url:8182/sparql"
query = "CLEAR GRAPH IRIref"
headers = {"content-type": "application/sparql-update"}
r = requests.post(url, data=query, headers=headers)
Note that the specification requires this to be a POST and have specific content type headers set. Neptune is fully SPARQL 1.1 compliant, so the relevant areas in the specification here are https://www.w3.org/TR/sparql11-protocol/#update-operation and https://www.w3.org/TR/sparql11-update/#clear.
Upvotes: 3