...
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 |
---|
|
curl -i -L -d 'email=testAdmin@mydomain.edu' -d 'password=Password' -d'@insert.sparql' 'http://localhost:8080/vivo/api/sparqlUpdate' |
Code Block |
---|
|
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 |
---|
|
curl -i -L -d 'email=testAdmin@mydomain.edu' -d 'password=Password' -d'@modify.sparql' 'http://localhost:8080/vivo/api/sparqlUpdate' |
Code Block |
---|
|
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.
...
|
curl -i -L -d 'email=testAdmin@mydomain.edu' -d 'password=Password' -d'@delete.sparql' 'http://localhost:8080/vivo/api/sparqlUpdate' |
Code Block |
---|
|
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. |
...