Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

These examples use the UNIX curl command to insert and delete data using the API.

Insert example

This example inserts a single RDF statement into the data model.

Code Block
languagebash
curl -i -L  -d 'email=testAdmin@mydomain.edu' -d 'password=Password' -d'@insert.sparql' 'http://localhost:8080/vivo/api/sparqlUpdate'
Code Block
titleinsert.sparql
update=INSERT DATA { 
   GRAPH <http://vitro.mannlib.cornell.edu/default/vitro-kb-2> { 
      <http://test.domain/ns#book1> 
          <http://purl.org/dc/elements/1.1/title> 
          "Fundamentals of Compiler Design" . 
    } 
}

Modify example

This example removes the previous statement, and inserts a replacement.

Code Block
languagebash
curl -i -L  -d 'email=testAdmin@mydomain.edu' -d 'password=Password' -d'@modify.sparql' 'http://localhost:8080/vivo/api/sparqlUpdate'
Code Block
titlemodify.sparql
update=DELETE DATA { 
   GRAPH <http://vitro.mannlib.cornell.edu/default/vitro-kb-2> { 
      <http://test.domain/ns#book1> 
          <http://purl.org/dc/elements/1.1/title> 
          "Fundamentals of Compiler Design" . 
    } 
}
INSERT DATA { 
   GRAPH <http://vitro.mannlib.cornell.edu/default/vitro-kb-2> { 
      <http://test.domain/ns#book1> 
          <http://purl.org/dc/elements/1.1/title> 
          "Design Patterns" . 
    } 
}

Delete example

This example removes the modified statement.

Code Block
languagebash
 

...

 curl -i -L  -d 'email=testAdmin@mydomain.edu' -d 'password=Password' -d'@delete.sparql' 'http://localhost:8080/vivo/api/sparqlUpdate'
Code Block
titledelete.sparql
update=DELETE DATA { 
   GRAPH <http://vitro.mannlib.cornell.edu/default/vitro-kb-2> { 
      <http://test.domain/ns#book1> 
          <http://purl.org/dc/elements/1.1/title> 
          "Design Patterns" . 
    } 
}

Enabling the API

Note

Before enabling the SPARQL update handler, you should secure the URL api/sparqlUpdate with HTTPS. Otherwise, email/password combinations will be sent across the network without encryption. Methods for securing the URL will depend on your site's configuration.

...