Search code examples
sparql

Sparql insert query failing


I am trying to run the below sparql query to insert data to my graph, but it's failing with the error: Error 400: Bad Request.

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX person: <http://example.com/data/person#>
PREFIX contact: <http://example.com/data/contact#>

INSERT
{ 
  person:p4595 contact:email "test1@example.com" ;
               contact:mobile "99483-43843" .
    
  person:p6593 contact:email "test2@example.com" ;
               contact:mobile "55351-56477" .
}

I have validated all the IRIs and triples are correct. Not sure why the query is failing.

Any help would be much appreciated. Thanks.


Solution

  • The insert syntax is incorrect. You should use either insert data or insert {...} followed by where {} (with empty {}). I have not run the query, but it should be something like this:

    PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
    PREFIX person: <http://example.com/data/person#>
    PREFIX contact: <http://example.com/data/contact#>
    
    INSERT DATA
    { 
      person:p4595 contact:email "test1@example.com" ;
                   contact:mobile "99483-43843" .
        
      person:p6593 contact:email "test2@example.com" ;
                   contact:mobile "55351-56477" .
    }