Search code examples
c#sparqldotnetrdfstardog

Sending SPARQL queries from C# using stardog: "cannot execute update query on read endpoint"


as the title says i'm trying to create triples using SPARQL queries from visualstudio. Using the same SPARQL queries inside stardog studio works, but when i try to send them from visualstudio using the stardogconnector i get the following error:

An unhandled exception of type 'VDS.RDF.Query.RdfQueryException' occurred in dotNetRDF.dll Additional information: A HTTP error (HTTP 400 Bad Request) occured while querying the Store. Store returned the following error message: {"message":"Cannot execute update query on read endpoint"} See aforementioned status line or inner exception for further details occurred

Here is the code:

StardogConnector stardog = new StardogConnector("http://localhost:5820", "dbtest", "admin", "password");
stardog.Begin();
string query = "INSERT DATA { <http://example/book1> dc:title \"test\"}";
stardog.Query(query);
stardog.Commit();

As i said, inserting the same query inside stardog studio gives the right result. The database is online, the connection works (password etc. is correct),... I just don't know what the error means. Can anybody help? I don't find much online about this error.


Solution

  • When query includes INSERT, UPDATE, or other write action, you have to change stardog.Query(query); (which is read-only) to stardog.Update(query); (which is apparently write-only).