2

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...

1ppCH
  • 276
  • 1
  • 3
  • 13
  • 3
    There's probably a separate endpoint for updates. – chrisis Feb 13 '19 at 19:00
  • 1
    that is correct, the URL for update request is most likely different, some triple stores do use `?update=` instead of `?query=`, but it depends on the config. – UninformedUser Feb 13 '19 at 20:03
  • 1
    @AKSW the use of `?update=` for update operations is mandatory according to the W3C specs, so if any triple stores use `?query=` for updates, they are non-compliant. – Jeen Broekstra Feb 14 '19 at 02:58
  • 1
    @JeenBroekstra Yeah, that's what I also thought w.r.t. the SPARQL protocol documents. But I just mentioned it that some configs might allow for different settings. Indeed not the popular triple stores/SPARQL APIs – UninformedUser Feb 14 '19 at 07:38

1 Answers1

6

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.

Jeen Broekstra
  • 21,642
  • 4
  • 51
  • 73