I am using fuseki embeded from a Java application :
Dataset ds = DatasetFactory.createTxnMem() ;
FusekiEmbeddedServer server = FusekiEmbeddedServer.create()
.setPort(3333)
.add("/ds", ds, true)
.build() ;
server.start() ;
The query endpoint is working fine and I can execute SELECT requests. However, when I want to insert values it does return a 204 HTTP code but no data is added to the graph. Here is what I did :
PREFIX dc: <http://purl.org/dc/elements/1.1/>INSERT DATA{ <http://example/book3> dc:title "A new book"}
<Response [204]>
then I select everything to see if it worked :
SELECT DISTINCT * WHERE {?s ?q ?o}
and I get
<?xml version="1.0"?>
<sparql xmlns="http://www.w3.org/2005/sparql-results#">
<head>
<variable name="s"/>
<variable name="q"/>
<variable name="o"/>
</head>
<results>
</results>
</sparql>
On the client side I have a basic python script :
port = 3333
test_add = 'PREFIX dc: <http://purl.org/dc/elements/1.1/>INSERT DATA{ <http://example/book3> dc:title "A new book"}'
try :
print requests.post("http://localhost:"+str(port)+"/ds", data={'update': test_add})
print urllib2.urlopen("http://localhost:"+str(port)+"/ds?query=SELECT%20DISTINCT%20*%20WHERE%20{?s%20?q%20?o}").read()
except Exception as e :
print e
This python script works now, it has been adapted from the answer below.