I'm using GraphDB Free and I'm trying to INSERT some triple(s) to the store with sparql. The query looks like a simple INSERT:
//Some Prefixes
INSERT DATA { subject predicate object }
I used Postman to POST the query in the request body to the SPARQL endpoint and dotNetRdf to submit the query to the SPARQL endpoint in code.
I receive the following error on both of the above ways:
MALFORMED QUERY: Encountered " "insert" "INSERT "" at line 5, column 1.
Was expecting one of:
"base" ...
"prefix" ...
"select" ...
"construct" ...
"describe" ...
"ask" ...
While submitting the same INSERT DATA { ... } in the Workbench in the SPARQL form works as expected, so the INSERT is ok.
In the documentation GraphDB Sparql Comliance it is mentioned that SPARQL 1.1 Update (including INSERT DATA) is supported. Does the Sparql endpoint not support the mentioned Spaqrl 1.1 UPDATE spec? Still looking through the documentation, not sure what I missed...
GraphDB uses the RDF4J REST API - this is an extension of the SPARQL 1.1 Protocol and the SPARQL Graph Store Protocol. The endpoint for SPARQL update operations is different from the endpoint for queries. You need to send your update to:
http://<host>/repositories/<repId>/statements
instead of just:
http://<host>/repositories/<repId>
Also: queries are sent using the ?query=
parameter. Updates, however, use the ?update=
parameter.
There's an example SPARQL update request in the REST API documentation.