%META:TOPICPARENT{name="VirtRWWInteractionACLcURL"}%
---+ LDP in Virtuoso - Simple Curl Examples
Simple curl examples showing Virtuoso's support for LDP (Linked Data Platform) Basic Containers.
Changes to resources made through the LDP REST interface are mirrored in the Conductor WebDAV UI.
Contents
%TOC%
---
---++ 1: Basic container lookup (GET on an LDP-BC)
---+++ Request - Basic container retrieval
curl -iH "Accept: text/turtle, */*;q=0.1" -u {username}:{password} "http://ods-qa.openlinksw.com/DAV/home/imitko/ldp-test/"
---+++ Response - Basic container retrieval
Note: The container was created prior to these tests and so was not empty.
HTTP/1.1 200 OK
Server: Virtuoso/07.10.3211 (Linux) x86_64-redhat-linux-gnu VDB
Connection: Keep-Alive
Date: Mon, 21 Jul 2014 13:57:27 GMT
Accept-Ranges: bytes
Content-Type: text/turtle
MS-Author-Via: DAV, SPARQL
Allow: GET,HEAD,POST,PUT,DELETE,OPTIONS,PROPFIND,PROPPATCH,COPY,MOVE,LOCK,UNLOCK,TRACE,PATCH
Accept-Patch: application/sparql-update
Accept-Post: text/turtle,text/n3,text/nt
Vary: Accept,Origin,If-Modified-Since,If-None-Match
Link: ; rel="type"
Link: ; rel="type"
Link: ; rel="first"
Link: ; rel="last"
Link: ; rel="meta"
Link: ; rel="acl"
ETag: a260c996d5e4c845ba49d29a21fcc754
X-SPARQL-default-graph: http://ods-qa.openlinksw.com/DAV/home/imitko/ldp-test/
Content-Length: 705
@prefix rdf: .
@prefix foaf: .
@prefix ldp: .
@prefix rdfs: .
rdf:type foaf:PersonalProfileDocument , ldp:Resource , rdfs:Resource .
rdf:type ldp:Container , ldp:BasicContainer ;
ldp:contains , .
rdf:type ldp:Container , ldp:BasicContainer .
---+++ Basic container lookup in SPARQL - Querying the LDP-BC graph
sparql SELECT * FROM WHERE { ?s ?p ?o }
returns
http://ods-qa.openlinksw.com/DAV/home/imitko/ldp-test/ http://www.w3.org/1999/02/22-rdf-syntax-ns#type http://www.w3.org/ns/ldp#Container
http://ods-qa.openlinksw.com/DAV/home/imitko/ldp-test/ http://www.w3.org/1999/02/22-rdf-syntax-ns#type http://www.w3.org/ns/ldp#BasicContainer
http://ods-qa.openlinksw.com/DAV/home/imitko/ldp-test/ http://www.w3.org/ns/ldp#contains http://ods-qa.openlinksw.com/DAV/home/imitko/ldp-test/foaf.ttl
http://ods-qa.openlinksw.com/DAV/home/imitko/ldp-test/ http://www.w3.org/ns/ldp#contains http://ods-qa.openlinksw.com/DAV/home/imitko/ldp-test/photos/
---
---++ 2: Creating an RDF resource (POST an RDF resource to an LDP-BC)
---+++ Request - Creating an RDF resource
curl -iX POST --data-binary @ldp-test-data/alice_foaf_profile.ttl -u {username}:{password} -H 'Content-Type: text/turtle' -H 'Slug:alice_foaf' 'http://ods-qa.openlinksw.com/DAV/home/imitko/ldp-test/'
---+++ Request Data - Creating an RDF resource
File: alice_foaf_profile.ttl
@prefix dc: .
@prefix foaf: .
<> a foaf:PersonalProfileDocument;
foaf:primaryTopic <#me> ;
dc:title 'Alice?s FOAF file' .
<#me> a foaf:Person;
foaf:name 'Alice Smith' .
---+++ Response - Creating an RDF resource
HTTP/1.1 201 Created
Server: Virtuoso/07.10.3211 (Linux) x86_64-redhat-linux-gnu VDB
Connection: Keep-Alive
Date: Mon, 21 Jul 2014 14:01:18 GMT
Accept-Ranges: bytes
Location: http://ods-qa.openlinksw.com/DAV/home/imitko/ldp-test/alice_foaf
MS-Author-Via: DAV, SPARQL
Allow: GET,HEAD,POST,PUT,DELETE,OPTIONS,PROPFIND,PROPPATCH,COPY,MOVE,LOCK,UNLOCK,TRACE,PATCH
Accept-Patch: application/sparql-update
Accept-Post: text/turtle,text/n3,text/nt
Vary: Accept,Origin,If-Modified-Since,If-None-Match
Link: ; rel="type"
Link: ; rel="meta"
Link: ; rel="acl"
Content-Type: text/turtle
Content-Length: 194
201 CreatedCreated
Resource /DAV/home/imitko/ldp-test/alice_foaf has been created.
Note: A second resource <http://ods-qa.openlinksw.com/DAV/home/imitko/ldp-test/bob_foaf>
was then created in the same way using:
curl -iX POST --data-binary @ldp-test-data/bob_foaf_profile.ttl -u {username}:{password} -H 'Content-Type: text/turtle' -H 'Slug: bob_foaf' 'http://ods-qa.openlinksw.com/DAV/home/imitko/ldp-test/'
with data file bob_foaf_profile.ttl
@prefix dc: .
@prefix foaf: .
<> a foaf:PersonalProfileDocument;
foaf:primaryTopic <#me> ;
dc:title 'Bob?s FOAF file' .
<#me> a foaf:Person;
foaf:name 'Bob Tate' .
---
---++ 3: Request - Basic container retrieval after resource creation
---+++ Request
curl -iH "Accept: text/turtle, */*;q=0.1" -u {username}:{password} "http://ods-qa.openlinksw.com/DAV/home/imitko/ldp-test/"
---+++ Response
HTTP/1.1 200 OK
Server: Virtuoso/07.10.3211 (Linux) x86_64-redhat-linux-gnu VDB
Connection: Keep-Alive
Date: Mon, 21 Jul 2014 15:35:15 GMT
Accept-Ranges: bytes
Content-Type: text/turtle
MS-Author-Via: DAV, SPARQL
Allow: GET,HEAD,POST,PUT,DELETE,OPTIONS,PROPFIND,PROPPATCH,COPY,MOVE,LOCK,UNLOCK,TRACE,PATCH
Accept-Patch: application/sparql-update
Accept-Post: text/turtle,text/n3,text/nt
Vary: Accept,Origin,If-Modified-Since,If-None-Match
Link: ; rel="type"
Link: ; rel="type"
Link: ; rel="first"
Link: ; rel="last"
Link: ; rel="meta"
Link: ; rel="acl"
ETag: a260c996d5e4c845ba49d29a21fcc754
X-SPARQL-default-graph: http://ods-qa.openlinksw.com/DAV/home/imitko/ldp-test/
Content-Length: 929
@prefix rdf: .
@prefix foaf: .
@prefix ldp: .
@prefix rdfs: .
@prefix ns4: .
rdf:type foaf:PersonalProfileDocument , ldp:Resource , rdfs:Resource .
ns4:
rdf:type ldp:Container , ldp:BasicContainer ;
ldp:contains , ns4:alice_foaf , , ns4:bob_foaf .
ns4:alice_foaf
rdf:type foaf:PersonalProfileDocument , ldp:Resource , rdfs:Resource .
rdf:type ldp:Container , ldp:BasicContainer .
ns4:bob_foaf
rdf:type foaf:PersonalProfileDocument , ldp:Resource , rdfs:Resource .
Both resources created by Test 2 are listed, confirming the resource creation was successful.
---
---++ 4: Updating a resource with PATCH and Sparql-Update
---+++ Pre-update - Resource description
curl -H -"Accept: text/turtle" -u {username}:{password} http://ods-qa.openlinksw.com/DAV/home/imitko/ldp-test/bob_foaf
---+++ Response - Resource description
@prefix rdf: .
@prefix foaf: .
@prefix owl: .
@prefix rdfs: .
@prefix ns4: .
@prefix ldp: .
@prefix dcterms: .
@prefix ns7: .
foaf:PersonalProfileDocument
rdf:type owl:Class , rdfs:Class .
rdfs:Resource
rdf:type owl:Class , rdfs:Class .
foaf:Person
rdf:type owl:Class , rdfs:Class .
ns4:bob_foaf
rdf:type foaf:PersonalProfileDocument , ldp:Resource , rdfs:Resource ;
dcterms:title "Bob\u2019s FOAF file" ;
foaf:primaryTopic ns7:me .
ns7:me
rdf:type foaf:Person ;
foaf:name "Bob Tate" .
---+++ Request - Resource update
curl -iX PATCH --data-binary @ldp-test-data/bob_foaf_profile_update.sparul -u {username}:{password} -H "Content-Type: application/sparql-update" http://ods-qa.openlinksw.com/DAV/home/imitko/ldp-test/bob_foaf
---+++ Request Data - Resource update
File: bob_foaf_profile_update.sparul
prefix foaf:
INSERT DATA {
foaf:img .
}
---+++ Response - Resource update
HTTP/1.1 204 No Content
Server: Virtuoso/07.10.3211 (Linux) x86_64-redhat-linux-gnu VDB
Connection: Keep-Alive
Date: Mon, 21 Jul 2014 15:41:30 GMT
Accept-Ranges: bytes
X-SPARQL-default-graph: http://ods-qa.openlinksw.com/DAV/home/imitko/ldp-test/bob_foaf
Content-Type: application/sparql-results+xml; charset=UTF-8
Content-Length: 489
---+++ Post-update - Resource description
@prefix rdf: .
@prefix foaf: .
@prefix owl: .
@prefix rdfs: .
@prefix ns4: .
@prefix ldp: .
@prefix dcterms: .
@prefix ns7: .
@prefix ns8: .
foaf:PersonalProfileDocument
rdf:type owl:Class , rdfs:Class .
rdfs:Resource
rdf:type owl:Class , rdfs:Class .
foaf:Person
rdf:type owl:Class , rdfs:Class .
ns4:bob_foaf
rdf:type foaf:PersonalProfileDocument , ldp:Resource , rdfs:Resource ;
dcterms:title "Bob\u2019s FOAF file" ;
foaf:primaryTopic ns7:me .
ns7:me
rdf:type foaf:Person ;
foaf:img ns8:avatar ;
foaf:name "Bob Tate" .
---
---++ 5: Creating a non-RDF (binary) resource (POST an image to an LDP-BC)
Test without slug header, using full target resource path
---+++ Request - LDP-NR creation
curl -iX PUT --data-binary @ldp-test-data/bob_avatar.png -u {username}:{password} -H "Content-Type: image/png" 'http://ods-qa.openlinksw.com/DAV/home/imitko/ldp-test/bob_avatar'
Note: Using a slug header to suggest the resource name when creating a resource is not supported. The full resource URL must be provided.
---+++ Response - LDP-NR creation
HTTP/1.1 201 Created
Server: Virtuoso/07.10.3211 (Linux) x86_64-redhat-linux-gnu VDB
Connection: close
Date: Tue, 22 Jul 2014 11:28:44 GMT
Accept-Ranges: bytes
Content-Type: image/png
Content-Length: 194
201 CreatedCreated
Resource /DAV/home/imitko/ldp-test/bob_avatar has been created.
---
---++ 6: Creating a child container
---+++ Request - Child container creation (Method 1)
curl -iH "Link: ; rel=?type?" -d '' -X POST -HSlug:photos_of_bob -HContent-Type:text/turtle -u {username}:{password} "http://ods-qa.openlinksw.com/DAV/home/imitko/ldp-test/"
---+++ Response - Child container creation (Method 1)
HTTP/1.1 201 Created
Server: Virtuoso/07.10.3211 (Linux) x86_64-redhat-linux-gnu VDB
Connection: Keep-Alive
Date: Mon, 21 Jul 2014 16:02:52 GMT
Accept-Ranges: bytes
Location: http://ods-qa.openlinksw.com/DAV/home/imitko/ldp-test/photos_of_bob/
MS-Author-Via: DAV, SPARQL
Allow: GET,HEAD,POST,PUT,DELETE,OPTIONS,PROPFIND,PROPPATCH,COPY,MOVE,LOCK,UNLOCK,TRACE,PATCH
Accept-Patch: application/sparql-update
Accept-Post: text/turtle,text/n3,text/nt
Vary: Accept,Origin,If-Modified-Since,If-None-Match
Link: ; rel="type"
Link: ; rel="type"
Link: ; rel="meta"
Link: ; rel="acl"
Content-Type: text/turtle
Content-Length: 198
201 CreatedCreated
Resource /DAV/home/imitko/ldp-test/photos_of_bob/ has been created.
---+++ Post-creation: Parent container description - Request
curl -iH "Accept: text/turtle, */*;q=0.1" -u {username}:{password} "http://ods-qa.openlinksw.com/DAV/home/imitko/ldp-test/"
---+++ Post-creation: Parent container description - Response
The response includes:
@prefix ns4: .
rdf:type ldp:Container , ldp:BasicContainer .
ns4:
rdf:type ldp:Container , ldp:BasicContainer ;
ldp:contains , , ns4:alice_foaf , , ns4:bob_foaf .
---+++ Request - Child container creation (Method 2)
curl --silent -iX POST --data-binary @ldp-test-data/alice_photo_container_creation.ttl -u {username}:{password} -H "Content-Type: text/turtle" -H "Slug: photos_of_alice" -H "Link: ; rel='type'" "http://ods-qa.openlinksw.com/DAV/home/imitko/ldp-test/"
---+++ Request Data - Child container creation (Method 2)
File: alice_photo_container_creation.ttl
@prefix ldp: .
@prefix dcterms: .
<> a ldp:Container, ldp:BasicContainer;
dcterms:title "Photos of Alice" ;
dcterms:description "This container will contain photos of Alice." .
---+++ Post-creation: Child container description - Request
curl -iH "Accept: text/turtle, */*;q=0.1" -u {username}:{password} "http://ods-qa.openlinksw.com/DAV/home/imitko/ldp-test/photos_of_alice/"
---+++ Post-creation: Child container description - Response
HTTP/1.1 200 OK
Server: Virtuoso/07.10.3211 (Linux) x86_64-redhat-linux-gnu VDB
Connection: Keep-Alive
Date: Mon, 21 Jul 2014 16:24:41 GMT
Accept-Ranges: bytes
Content-Type: text/turtle
MS-Author-Via: DAV, SPARQL
Allow: GET,HEAD,POST,PUT,DELETE,OPTIONS,PROPFIND,PROPPATCH,COPY,MOVE,LOCK,UNLOCK,TRACE,PATCH
Accept-Patch: application/sparql-update
Accept-Post: text/turtle,text/n3,text/nt
Vary: Accept,Origin,If-Modified-Since,If-None-Match
Link: ; rel="type"
Link: ; rel="type"
Link: ; rel="first"
Link: ; rel="last"
Link: ; rel="meta"
Link: ; rel="acl"
ETag: 55e21d87c87434c647ac893badd6bbce
X-SPARQL-default-graph: http://ods-qa.openlinksw.com/DAV/home/imitko/ldp-test/photos_of_alice/
Content-Length: 377
@prefix rdf: .
@prefix ldp: .
@prefix dcterms: .
rdf:type ldp:Container , ldp:BasicContainer ;
dcterms:title "Photos of Alice" ;
dcterms:description "This container will contain photos of Alice." .
---
---++ 7: Deleting a resource
---+++ Request - Resource deletion
curl -iX DELETE -u {username}:{password} 'http://ods-qa.openlinksw.com/DAV/home/imitko/ldp-test/bob_foaf'
---+++ Response - Resource deletion
HTTP/1.1 204 No Content
Server: Virtuoso/07.10.3211 (Linux) x86_64-redhat-linux-gnu VDB
Connection: Keep-Alive
Content-Type: text/html; charset=UTF-8
Date: Fri, 25 Jul 2014 12:25:30 GMT
Accept-Ranges: bytes
MS-Author-Via: DAV, SPARQL
Allow: GET,HEAD,POST,PUT,DELETE,OPTIONS,PROPFIND,PROPPATCH,COPY,MOVE,LOCK,UNLOCK,TRACE,PATCH
Accept-Patch: application/sparql-update
Accept-Post: text/turtle,text/n3,text/nt
Vary: Accept,Origin,If-Modified-Since,If-None-Match
Link: ; rel="meta"
Link: ; rel="acl"
Content-Length: 0
---+++ Post-deletion: Resource description - Request
curl -iH -"Accept: text/turtle" -u {username}:{password} 'http://ods-qa.openlinksw.com/DAV/home/imitko/ldp-test/bob_foaf'
---+++ Post-deletion: Resource description - Response
HTTP/1.1 404 Not Found
Server: Virtuoso/07.10.3211 (Linux) x86_64-redhat-linux-gnu VDB
Connection: Keep-Alive
Content-Type: text/html; charset=UTF-8
Date: Fri, 25 Jul 2014 12:27:08 GMT
Accept-Ranges: bytes
Content-Length: 218
404 Not Found
Not found
Resource /DAV/home/imitko/ldp-test/bob_foaf not found.